Skip to content

Fix mbe play function segfault#130

Open
peads wants to merge 14 commits into
szechyjs:masterfrom
peads:fix_mbe_play_fn_segfault
Open

Fix mbe play function segfault#130
peads wants to merge 14 commits into
szechyjs:masterfrom
peads:fix_mbe_play_fn_segfault

Conversation

@peads

@peads peads commented Feb 7, 2023

Copy link
Copy Markdown

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::playMbeFiles was not closing the file upon completion of the read loop (I found specifically when I added a call to perror that 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. using feof incorrectly: https://stackoverflow.com/a/36165087). Digging deeper, I found that there was a general lack of error checking in dsd_file::openMbeInFile (which the aforementioned function calls). So, I added some there as well.

ra1nb0w and others added 14 commits December 22, 2020 16:38
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.
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

Successfully merging this pull request may close these issues.

5 participants