Fix mbe play function segfault#130
Open
peads wants to merge 14 commits into
Open
Conversation
Thanks to N0YKG for the fix! I am just making the PR :)
…e currently read file, which was causing segfaults for large numbers of mbe files being read in. Extracted reader function calls to typedefed pointer, s.t. since the file type only needs to be read per file, it could be set to a generic function pointer thus cleaning up the read loop. Fixed end conditions for both the while and for loops, s.t. they break on exit flag, and their respective conditions. Removed redundant cleanup function call since the caller calls it on return of the play function anyway.
…extensible beyond EOF being defined as -1 in glibc. Changed expected EOF in playMbeFile to be handled specially (i.e. not sent to error handler) because it's more likely than not to be expected, and in any case, we can just trying playing the next file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In lieu of creating an issue and assigning it to myself, I'm just gonna describe the problem here:
I like to play a lot of mbe files that have accumulated over time, say overnight. Occasionally, the replay would just segfault and die. Upon investigation I found that the
dsd_mbe::playMbeFileswas not closing the file upon completion of the read loop (I found specifically when I added a call toperrorthat it was getting "Too many open files"); it also wasn't testing generally for errors while reading nor was it handling EOF detection correctly (i.e. usingfeofincorrectly: https://stackoverflow.com/a/36165087). Digging deeper, I found that there was a general lack of error checking indsd_file::openMbeInFile(which the aforementioned function calls). So, I added some there as well.