-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Potential infinite loop in sound mixer #23
Comments
I really don't think it is, and where MojoAL has a problem with this, I consider it a MojoAL bug. |
@icculus I think following line may also fail in case of irregular sized buffer remains: I ended up with a following temp hotfix for now (hopefully, the math is right...):
But I cannot tell whether this is technically a correct thing to do; as I never worked with SDL audio functions before, so idk if it's okay to pass irregular lengths into SDL_AudioStreamPut, and also what will happen if |
@icculus this is the only thing we currently have different from mojoAL upstream (this commit), it would be nice if at least the hotfix could be in at least until some better fix is done. |
I rewrote this ticket slightly after more investigation. It appears the origin of it is similar to one mentioned in #18: in our program we do not ensure fixed and "even" size of queued buffers, and simply pass as much as decoder gave to us.
While above is our program's flaw, there's a place in mojoAL where it lacks a safety check, and is capable of going into the infinite loop.
For the reference, we experienced this with the following wav file, because SDL_Sound's decoder was retrieving unevenly sized buffers from it:
random6.zip
The location in the mojoAl's code where the infinite loop occurs:
mojoAL/mojoal.c
Lines 1423 to 1430 in bfaf2f2
What causes infinite loop is this:
const int framesput = (buffer->len - src->offset) / bufferframesize
- in this expression(buffer->len - src->offset)
appears to be less thanbufferframesize
, and this framesput equals zero.src->offset
never advances, andwhile
exit condition will be never met.I suppose that mojoAl could at least have an assertion and/or safety break there, to not hang in that loop.
The text was updated successfully, but these errors were encountered: