| Summary: | NULL pointer access in ALSA_GetDeviceBuf results in a crash | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Ellie <etc0de> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P1 | Keywords: | target-2.0.0 |
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
|
Description
Ellie
2011-12-09 16:13:33 UTC
Sorry, it seems that rather this->hidden or the _THIS parameter is null. But you'll figure out yourself if you look at the code line valgrind points out. Any additional information I could possibly provide? Is this possibly a pulseaudio bug which SDL cannot fix? (Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.) Tagging a bunch of bugs as target-2.0.0, Priority 1. This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible. That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship. Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment. Thanks! --ryan.
tl;dr: we already fixed this, unintentionally.
Ok, here's what's going on with this bug.
I accidentally fixed this here...
http://hg.libsdl.org/SDL/rev/7f22b9ba218f#l2.84
...where I changed OpenDevice to return -1 on failure instead of 0. You'll note that one I changed there was already returning -1, though, which the higher level code would have treated as success for being non-zero.
Compliments of the Steam Runtime SDK's debug builds, I could set a breakpoint on that failing pulse_prepare() to see where it gets called, and sure enough, it's on the stack above where that wrong return value gets used. It doesn't fail on my machine (but the first call to it fails correctly without killing the connection, so it's probably something they fixed in libasound), but let's pretend it still does fail epically.
Having failed, our ALSA code has cleaned itself up, including freeing/NULLing this->hidden, and returned an incorrect -1 instead of the zero it should have.
Amazingly, we get as far as spinning a thread, and that background thread is the first thing that calls into the ALSA code again: GetDeviceBuf. It then dereferences a NULL pointer and blows up.
Since we corrected the return value, the ALSA code reports the failure properly, and the SDL audio code cleans up and reports the OpenDevice failure to the app as it should, without crashing.
So we're good here! :)
--ryan.
|