Bug 183074 - Phonon kded module does not check return code of pa_context_connect
Summary: Phonon kded module does not check return code of pa_context_connect
Alias: None
Product: Phonon
Classification: Frameworks and Libraries
Component: kded module for audio device listing (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Matthias Kretz
Depends on:
Reported: 2009-02-03 23:18 UTC by David Sansome
Modified: 2009-02-11 23:26 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:

Check the return code of pa_context_connect (1.06 KB, patch)
2009-02-03 23:20 UTC, David Sansome

Note You need to log in before you can comment on or make changes to this bug.
Description David Sansome 2009-02-03 23:18:37 UTC
Version:            (using KDE 4.2.0)
Compiler:          gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) 
OS:                Linux
Installed from:    Ubuntu Packages

After starting KDE I experienced a lot of strange behaviour, including:
1) Searching in the Kickoff menu causes plasma to hang
2) Clicking the "Service Manager" icon in system settings would hang
3) Sometimes using an Alt+something shortcut, like Alt+F2, would cause the Alt key to become "stuck".  Any further actions after releasing the Alt key would occur as if the Alt key were still pressed - for example dragging inside a window would move it (as Alt+drag does).

I narrowed the problem down to kded, as killing kded4 and restarting it would solve all of the above for a little while.  I attached gdb to kded4 while the problems were occuring and got a backtrace.  It was blocking in the pulse audio event loop.  Important stack frames are (I had to write them down - couldn't copy+paste):


It looked like the Phonon kded plugin was entering the pulse audio event loop and never exiting.  I did a little digging and discovered that phononserver.cpp was not checking the return code of pa_context_connect, and going ahead and starting the event loop even if it couldn't connect to the pulse server.  The context state callback that it waits for was then never occuring, and it would never exit the event loop.

I'm attaching a patch which solves the issue for me.  It's against SVN trunk as of Feb 3rd.
Comment 1 David Sansome 2009-02-03 23:20:22 UTC
Created attachment 30936 [details]
Check the return code of pa_context_connect

This patch fixes the problem for me
Comment 2 David Sansome 2009-02-10 23:07:18 UTC
Are there any comments on this?

If not I'd like to commit it.
Comment 3 Matthias Kretz 2009-02-11 21:42:48 UTC
David, the patch looks good. The pulseaudio docs and examples don't really tell that you have to do this, but I'm pretty sure that the patch is right (I once tried to get help about this hang on #pulseaudio but they didn't have an idea).

Please commit to trunk and KDE 4.2 branch.
Comment 4 David Sansome 2009-02-11 23:26:15 UTC
Thanks Matthias!

I've committed to trunk and the KDE 4.2 branch.