(Translated by https://www.hiragana.jp/)
Fix mbe play function segfault by peads · Pull Request #130 · szechyjs/dsd · GitHub
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

Fix mbe play function segfault #130

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

peads
Copy link

@peads peads commented Feb 7, 2023

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