Skip to content

3.3 bugfix - #104

Merged
ayzk merged 4 commits into
masterfrom
3.3_bugfix
Sep 24, 2025
Merged

ayzk merged 4 commits into
masterfrom
3.3_bugfix

Conversation

@ayzk

@ayzk ayzk commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@ayzk
ayzk requested a review from Copilot September 24, 2025 00:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug related to handling cases where data dimensions are smaller than the block size in sampling and profiling functions. The changes prevent potential out-of-bounds access and infinite loops that could occur when dimension sizes are less than the block size used for sampling or compression operations.

  • Added dimension validation checks in sampling and profiling functions to prevent processing when any dimension is smaller than the required block size
  • Added similar validation in the compression algorithm to disable tuning when dimensions are insufficient
  • Ensures early return from functions when block operations would be invalid

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
include/SZ3/utils/Sample.hpp Added dimension validation checks in profiling_block, sample_blocks, and sampleBlocks functions to prevent processing with insufficient dimension sizes
include/SZ3/api/impl/SZAlgoInterp.hpp Added validation to disable tuning in compression algorithm when dimensions are smaller than sample block size

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread include/SZ3/utils/Sample.hpp Outdated

size_t dimx = dims[0], dimy = dims[1], dimz = dims[2], dimw = dims[3], dimyzw = dimy * dimz * dimw,
dimzw = dimz * dimw;
if (dimx < block_size || dimy < block_size || dimz < block_size || dimw < block_size) {

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.

Suggested change
if (dimx < block_size || dimy < block_size || dimz < block_size || dimw < block_size) {
if(dimx < block_size || dimy < block_size || dimz < block_size || dimw < block_size) {

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/utils/Sample.hpp Outdated
}
} else if constexpr (N == 3) {
size_t dimx = dims[0], dimy = dims[1], dimz = dims[2], dimyz = dimy * dimz;
if (dimx < block_size || dimy < block_size || dimz < block_size) {

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.

Suggested change
if (dimx < block_size || dimy < block_size || dimz < block_size) {
if (dimx < block_size || dimy < block_size || dimz < block_size) {

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/utils/Sample.hpp Outdated
}
} else if constexpr (N == 2) {
size_t dimx = dims[0], dimy = dims[1];
if (dimx < block_size || dimy < block_size) {

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.

Suggested change
if (dimx < block_size || dimy < block_size) {
if (dimx < block_size || dimy < block_size) {

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/utils/Sample.hpp Outdated
}
} else {
size_t dimx = dims[0];
if (dimx < block_size) {

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.

Suggested change
if (dimx < block_size) {
if (dimx < block_size) {

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/utils/Sample.hpp Outdated
} else if constexpr (N == 3) {
if (dims[0] < block_size || dims[1] < block_size || dims[2] < block_size) {
return;
}

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace after the closing brace should be removed.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/utils/Sample.hpp Outdated
} else if constexpr (N == 2) {
if (dims[0] < block_size || dims[1] < block_size) {
return;
}

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace after the closing brace should be removed.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/utils/Sample.hpp Outdated
} else if constexpr (N == 1) {
if (dims[0] < block_size) {
return;
}

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace after the closing brace should be removed.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
Comment thread include/SZ3/api/impl/SZAlgoInterp.hpp Outdated
bool to_tune = pow(sampleBlockSize + 1, N) <= 0.05 * conf.num; // to further revise
if (to_tune) {
for (size_t i = 0; i < N; i++) {
if(conf.dims[i] < sampleBlockSize) {

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space between 'if' and the opening parenthesis. Should be 'if (' instead of 'if('.

Suggested change
if(conf.dims[i] < sampleBlockSize) {
if (conf.dims[i] < sampleBlockSize) {

Copilot uses AI. Check for mistakes.
@ayzk
ayzk requested a review from Copilot September 24, 2025 00:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

include/SZ3/api/impl/SZAlgoInterp.hpp:1

  • The loop variable i should be of type size_t or uint to match the template parameter N which is declared as uint. Using int may cause comparison warnings or undefined behavior when N is larger than INT_MAX.
#ifndef SZ3_SZALGO_INTERP_HPP

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ayzk
ayzk merged commit 635ddc3 into master Sep 24, 2025
@ayzk
ayzk deleted the 3.3_bugfix branch September 24, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants