Repository navigation
Conversation
bytes_in_headers and bytes_in_data_packets are NumPy uint32 scalars. Under NumPy 2 (NEP 50), subtracting one from a Python int file size above 2**32 raises OverflowError. Cast to int before doing file-size arithmetic.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
`_read_nev_data` took `header_size` straight from `self._nev_basic_header["bytes_in_headers"]`, a NumPy `uint32` scalar. Under NumPy 2 (NEP 50), `self._get_file_size(filename) - header_size` then raises `OverflowError: Python integer ... out of bounds for uint32` for any `.nev` over 4 GiB, before the memmap is even created. `_get_nev_rec_times` has the same problem with `bytes_in_data_packets`.
Both values are now cast with `int()`. I checked the other places where header fields meet file sizes or offsets: the NSx paths (2.1, 2.2/3.0 and PTP) already use Python ints, so they are unchanged.
The new test, `test_nev_over_4_gib_does_not_overflow`, needs no data: it stubs a 5 GiB file size and a header with `uint32` fields, mocks `np.memmap`, and checks the `offset` and `shape` passed to it for both methods. It fails with the `OverflowError` above on current master (I checked each of the two fixes on its own) and passes with this change. The Blackrock rawio and io tests pass (32 passed).
This came up with a 4.6 GB spec 2.2 file written by Ripple Trellis. I have not run that file, or any real file over 4 GiB, through this branch; the test is the only check at that size.