Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted EDF file leads to segfault #70

Open
danjjl opened this issue Feb 28, 2020 · 4 comments
Open

Corrupted EDF file leads to segfault #70

danjjl opened this issue Feb 28, 2020 · 4 comments

Comments

@danjjl
Copy link

danjjl commented Feb 28, 2020

A corrupted EDF file causes python to segfault with the following error:

python(14094,0x1098325c0) malloc: *** error for object 0x7faae04a9e00: pointer being freed was not allocated
python(14094,0x1098325c0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

edfbrowser reports the following error on the EDF file:

Datarecord duration is 1.000000000000 but timestep between
datarecord 70407 and preceding datarecord is 1.678000000000.
Offset from start of file: 0x47DC9E58

Stopped at the first error, additional errors may be present.

A fix to this bug would be to throw an exception instead of crashing python.

@skjerns
Copy link
Collaborator

skjerns commented Feb 28, 2020

do you have a sample file?

the error is thrown from the c-library (edflib). to catch it we will probably need to add some additional code in the edflib library.

@danjjl
Copy link
Author

danjjl commented Feb 28, 2020

Here is a fake corrupted file that generates a maloc
test_segfault.edf.zip

(File is actually corrupted, i.e. file does not meet EDF+ specification --> suggestion is not to fix loading of this particular file but more not to segfault and cleanly report an error)

@skjerns
Copy link
Collaborator

skjerns commented Feb 29, 2020

As I suspected, the segfault cannot be caught in Python.

I would need to alter the C-source code of pyedflib and throw a Python exception there. I don't want to break anything by tempering with edflib, so at this moment it's one one of the priorities.

@skjerns skjerns closed this as completed Feb 29, 2020
@skjerns skjerns reopened this Mar 5, 2020
@DimitriPapadopoulos
Copy link
Contributor

The issue should have been opened against upstream EDFlib. It looks like recent unit tests of that library do report an error without crashing when reading your file. Hopefully, this segfault will go away when upgrading to a more recent version 1.24 of that library (#230).

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

No branches or pull requests

3 participants