Skip to content

Blackrock: fix OverflowError reading .nev files over 4 GiB - #1929

Open
cboulay wants to merge 1 commit into
NeuralEnsemble:masterfrom
cboulay:nev-over-4gib
Open

cboulay wants to merge 1 commit into
NeuralEnsemble:masterfrom
cboulay:nev-over-4gib

Conversation

@cboulay

@cboulay cboulay commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

`_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.

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

No deployments
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.

1 participant