After much debugging, I found the problem with the code. The problem is with the memory mapped section of code causing corruption. This problem is likely specific to Windows due to the "nt" if statement. This is probably why it was not caught.
elif seek_past_header:
# Efficiently find the header-data seperator line no matter how big
# any header line is
datafilehandle.seek(0)
if os.name == "nt":
m = mmap.mmap(datafilehandle.fileno(), 0, access=mmap.ACCESS_READ)
else:
m = mmap.mmap(datafilehandle.fileno(), 0,
mmap.MAP_PRIVATE, mmap.PROT_READ)
seek_past_header_pos = m.find(b'\n\n')
if seek_past_header_pos == -1:
raise NrrdError('Invalid NRRD: Missing header-data separator line')
datafilehandle.seek(seek_past_header_pos + 2)
I am confident this is the issue because setting seek_past_header to False makes the test case work.
Hello,
Just wanted to say that I like this library and it has made my life a lot easier than having to write one myself.
I kept having the following issue when trying to read specific NRRD files from memory:
I simplified my code down into the following that should trigger the error:
My machine is Windows 10 x64 with 8GB RAM.
Issue
After much debugging, I found the problem with the code. The problem is with the memory mapped section of code causing corruption. This problem is likely specific to Windows due to the "nt" if statement. This is probably why it was not caught.
I am confident this is the issue because setting
seek_past_header
to False makes the test case work.I will submit a PR to fix this soon hopefully.