nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
634 stars 258 forks source link

Might lead to MemoryError on i386 #1307

Open yarikoptic opened 3 months ago

yarikoptic commented 3 months ago

Just making a record of an instance of a test fail we got reported against heudiconv while building debian package on good old i386 architecture:

https://salsa.debian.org/med-team/heudiconv/-/jobs/5439470

heudiconv/cli/run.py:30: in main
    workflow(**kwargs)
heudiconv/main.py:410: in workflow
    study_sessions = get_study_sessions(
heudiconv/parser.py:221: in get_study_sessions
    seqinfo_dict = group_dicoms_into_seqinfos(
heudiconv/dicoms.py:324: in group_dicoms_into_seqinfos
    mwinfo = validate_dicom(filename, dcmfilter)
heudiconv/dicoms.py:157: in validate_dicom
    mw = dw.wrapper_from_file(fl, force=True, stop_before_pixels=True)
/usr/lib/python3/dist-packages/nibabel/nicom/dicomwrappers.py:58: in wrapper_from_file
    dcm_data = pydicom.dcmread(fobj, *args, **kwargs)
/usr/lib/python3/dist-packages/pydicom/filereader.py:1030: in dcmread
    dataset = read_partial(
/usr/lib/python3/dist-packages/pydicom/filereader.py:852: in read_partial
    dataset = read_dataset(
/usr/lib/python3/dist-packages/pydicom/filereader.py:427: in read_dataset
    raw_data_element = next(de_gen)
/usr/lib/python3/dist-packages/pydicom/filereader.py:207: in data_element_generator
    fp_read(length) if length > 0
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <nibabel.openers.ImageOpener object at 0xf1f76fd0>, size = 1768444706
    def read(self, size: int = -1, /) -> bytes:
>       return self.fobj.read(size)
E       MemoryError
/usr/lib/python3/dist-packages/nibabel/openers.py:223: MemoryError
effigies commented 3 months ago

Looks like a pydicom error?

yarikoptic commented 3 months ago

not assigning blame here ;) but indeed could be really triggered by pydicom - I guess worth debugging and see what length it figured wanting to read

effigies commented 3 months ago

Looks like that's being unpacked from the first 8 bytes of the frame, so it's not something we're passing.

https://github.com/pydicom/pydicom/blob/v2.4.4/pydicom/filereader.py#L206-L211