Skip to content

Commit a03f03a

Browse files
committed
[BUG] Fix overflow when seeking through files
This can happen whenever the number of cells of a given resolution in a given file is larger than (2**31-1) / 8 / nvar, where nvar is the number of variables being tracked (e.g., for density + pressure + velocities, that'd be 5
1 parent a083893 commit a03f03a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

yt/frontends/ramses/io_utils.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ ctypedef np.int32_t INT32_t
1616
ctypedef np.int64_t INT64_t
1717
ctypedef np.float64_t DOUBLE_t
1818

19-
cdef int INT32_SIZE = sizeof(np.int32_t)
20-
cdef int INT64_SIZE = sizeof(np.int64_t)
21-
cdef int DOUBLE_SIZE = sizeof(np.float64_t)
19+
cdef INT64_t INT32_SIZE = sizeof(np.int32_t)
20+
cdef INT64_t INT64_SIZE = sizeof(np.int64_t)
21+
cdef INT64_t DOUBLE_SIZE = sizeof(np.float64_t)
2222

2323

24-
cdef inline int skip_len(int Nskip, int record_len) noexcept nogil:
24+
cdef inline INT64_t skip_len(INT64_t Nskip, INT64_t record_len) noexcept nogil:
2525
return Nskip * (record_len * DOUBLE_SIZE + INT64_SIZE)
2626

2727

@@ -68,7 +68,7 @@ def read_amr(FortranFile f, dict headers,
6868
)
6969
# Initialize values
7070
max_level = 0
71-
cdef int record_len
71+
cdef INT64_t record_len
7272

7373
for ilevel in range(nlevelmax):
7474
for icpu in range(ncpu_and_bound):

0 commit comments

Comments
 (0)