Don't crash when writing files on 64bit machines #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
If you tried to write an EDF file on an amd64 machine (and possible even any other machine) using this Python module, you ran into a segmentation fault:
This happens because the
fopen64
and other functions are not defined. The compiler even warns about that and I thought about making that warning fatal while writing this patch...The problem is that if a reference is undefined, the functions will be assumed, as per C standard, to return an int datatype, which is not large enough to hold a pointer to
FILE*
on 64bit devices. Therefore, the pointer gets smashed and any subsequent action on it is doomed to fail and crash the program.The solution is to always compile with large file support, so the respective functions are defined. This will also get rid of almost all compiler warnings (the edflib.c file even contains a note about this at its top, so it looks like its original author was aware of this problem).
To reproduce the bug, just try to run the
demo/writeEDFFile.py
on an amd64 machine.Cheers,
Matthias