-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for potential integer under/overflow issue with reading very large files #631
Fix for potential integer under/overflow issue with reading very large files #631
Conversation
…bit qsort comparator return value
@briandobbins
E3SM/SCREAM uses the box rearranger by default, which might explain why you did not reproduce this issue on the ne1024/128-level grids. To test the subset rearranger in E3SM/SCREAM, you need to explicitly change PIO_REARRANGER (default value is 1) to 2: |
Original PR text
|
@dqwu : Can you also add a simple C unit test for this case (testing qsort with simple arrays containing large PIO offset values)? |
Yes, we can create another PR to add a simple C unit test that reproduces the integer underflow/overflow issue, which is expected to fail without the patch in this PR. |
This PR adds additional test cases to ensure the internal comparison function compare_offsets() correctly handles the differences between 64-bit offset values, including edge cases with extremely large or small values. The new test cases would fail with the current master branch, and they are expected to be fixed by PR #631. * dqwu/test_compare_offsets: Adding 64-bit offset comparison test cases to test_compare_offsets()
The potential integer under/overflow issue is now reproducible with an updated C unit test in PR #632 (to be fixed by this PR). |
Fix overflow/underflow issues during qsort for the SUBSET rearranger. The comparator function given to the qsort call in the rearranger returns a 32-bit integer, but the operands can be 64-bit. Depending on the difference in value, you can get an overflow or underflow, which means you read an incorrect amount of data. * briandobbins/compare_offsets_fix: Fixes integer under/overflow issue when casting 64-bit offsets to 32-bit qsort comparator return value
This PR adds additional test cases to ensure the internal comparison function compare_offsets() correctly handles the differences between 64-bit offset values, including edge cases with extremely large or small values. The new test cases would fail with the current master branch, and they are expected to be fixed by PR #631.
Fix overflow/underflow issues during qsort for the SUBSET
rearranger.
The comparator function given to the qsort call in the rearranger
returns a 32-bit integer, but the operands can be 64-bit. Depending
on the difference in value, you can get an overflow or underflow,
which means you read an incorrect amount of data.