Bug 536786

Summary: blueman-applet-1.21-1.fc{11|12} segfaults on startup
Product: [Fedora] Fedora Reporter: Bradley <bbaetz>
Component: bluemanAssignee: Juan Manuel Rodriguez <nushio>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 12CC: dmalcolm, ivazqueznet, james.antill, jonathansteffan, katzj, linux, nushio, pepis
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: abrt_hash:a75852aa11efb9034bcb0f0d61ec42c8d3aea28c
Fixed In Version: 1.21-2.fc11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-11-20 00:37:23 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Attachments:
Description Flags
File: backtrace
none
applet log
none
Better log
none
Backtrace from blueman-applet from blueman-1.21-1.fc11.i586 triggered by restarting pulseaudio (via killall pulseaudio) none

Description Bradley 2009-11-11 06:37:44 EST
abrt detected a crash.

Comment: Crashes on startup
Attached file: backtrace
cmdline: /usr/bin/python /usr/bin/blueman-applet
component: python
executable: /usr/bin/python
kernel: 2.6.31.5-127.fc12.x86_64
package: python-2.6.2-2.fc12
rating: 4
reason: Process was terminated by signal 11
Comment 1 Bradley 2009-11-11 06:37:48 EST
Created attachment 369008 [details]
File: backtrace
Comment 2 Bradley 2009-11-11 06:45:19 EST
This is from starting blueman-applet from blueman-1.21-1.fc12.x86_64 (currently in updates-testing)
Comment 3 Dave Malcolm 2009-11-11 19:24:04 EST
Thanks for filing this bug report.

How reproducable is this problem?

I've been trying to reproduce this behavior, but haven't managed to see it yet.

If you run it from a terminal, is there any output?

Notes to self: looking at the backtrace, frames 26 and below show a pygtk application starting up.
An event comes in frame 24/25, and is dispatched into pulsecore (frames 23->18; pstream_packet_callback, pa_context_simple_ack_callback) which calls a Python callback (down to frame 15), which invokes python code down to frame 3, where it calls back into native code; whereupon the segfault happens, calling Py_DecRef on some object pointer.
Comment 4 Bradley 2009-11-12 03:09:28 EST
So yesterday it was crashing all the time, now it happens on login (I haven't tried to see if its on each login or only the first for the reboot)

It happens all the time, even with my hardware kill switch on, and on my laptop that removes the BlueTooth adapter from the USB bus entirely, so this should in theory be reproducable for anyone. I don't have another PC to test with, though.

Now it starts on the second run. there's nothing useful in .xsession-errors for the first crash - is there some way of capturing the full console logs that appears if I run it manually from an xterm?

I have another crash that I can upload if you want, but I assume its the same. After manually starting blueman-applet, this is being sent through the new blueman with BT tethering to my iPhone, so it definitely works now(*)

(*) I had to manually run dhclient because NM doesn't recognise the bnap device, but thats a separate bug
Comment 5 Bradley 2009-11-12 03:15:57 EST
Created attachment 369153 [details]
applet log

OK, I can reproduce this 100%. Based on the pulseaudio bits in the log, I tried:

1. killall pulseaudio
2. blueman-applet
3. Crash

Second time it works, because pulseaudio is started. It looks like the applet starts up pulseaudio but then tries to use it before its ready, and crashes?

Log attached, but its truncated (presumably python's buffering when redirecting the a file loses the output when it segfaults). I'll play arround and try to get something better when I'm not using bluetooth for my internet connection :)
Comment 6 Bradley 2009-11-12 07:24:59 EST
*** Bug 537080 has been marked as a duplicate of this bug. ***
Comment 7 Bradley 2009-11-12 07:28:50 EST
Created attachment 369206 [details]
Better log

This was run with the hardware kill switch enabled (ie no BT USB adapter) after doing |killall pulseaudio|
Comment 8 Dave Malcolm 2009-11-12 09:02:20 EST
Thanks for the info.

Looks like a bug in the blueman candidate update package, or, at least, a bad interaction between various components.

I see this is for https://admin.fedoraproject.org/updates/F12/FEDORA-2009-11145 and that you've already reported this there (thanks!)

I just now managed to reproduce this on an i386 F11 box with the F11 version of that update (https://admin.fedoraproject.org/updates/F11/FEDORA-2009-11065 ); I've commented there accordingly.
Comment 9 Dave Malcolm 2009-11-12 09:40:58 EST
Segfault seems to be happening in /usr/lib/python2.6/site-packages/blueman/main/PulseAudioUtils.py

within the:
			pythonapi.Py_DecRef(data)
call here:
	def simple_callback(self, handler, function, *args):
				
		def wrapper(context, res, data):
			if handler:
				handler(res)
			pythonapi.Py_DecRef(data)
			
		cb = pa_context_index_cb_t(wrapper)
		pythonapi.Py_IncRef(py_object(cb))
		
		args += (cb, py_object(cb))
		
		self.pa.pa_operation_unref(function(self.pa_context, *args))
Comment 10 Dave Malcolm 2009-11-12 09:41:38 EST
(indentation of above mangled by bugzilla, alas)
Comment 11 Dave Malcolm 2009-11-12 09:49:42 EST
Created attachment 369224 [details]
Backtrace from blueman-applet from blueman-1.21-1.fc11.i586 triggered by restarting pulseaudio (via killall pulseaudio)
Comment 12 Dave Malcolm 2009-11-12 10:01:35 EST
If I change line 173 of /usr/lib/python2.6/site-packages/blueman/main/PulseAudioUtils.py
from
     pythonapi.Py_DecRef(data)
to
     pythonapi.Py_DecRef(py_object(data))
then the segfault seems to go away.  Not yet sure if it's the correct fix.
Comment 13 Dave Malcolm 2009-11-12 14:06:27 EST
Adding the additional py_object() wrapper looks like a reasonable way to fix up that code - the ctypes function call is expecting a PyObject* that's a _ctypes.SimpleType, storing a reference to the underlying PyObject*, rather than simply the original PyObject*.

Having said that, does libpulse have python bindings?  Doing it all through ctypes is fragile and is likely to break (e.g. if anything changes in the libpulse API, you're going to have to manually update it there, and in every other such user of the API, rather than fixing it in one place).
Comment 14 Dave Malcolm 2009-11-12 14:07:27 EST
(I don't have a launchpad account, so I can't send this upstream)
Comment 15 Juan Manuel Rodriguez 2009-11-12 14:09:27 EST
I talked to walmis, the Blueman developer. Blueman 1.21-2 should arrive shortly in the testing repos.
Comment 16 Juan Manuel Rodriguez 2009-11-12 14:10:02 EST
Forgot to add, he's using
 pythonapi.Py_DecRef(py_object(data))

To fix the issue, as you suggested, Dave.
Comment 17 Fedora Update System 2009-11-12 14:23:27 EST
blueman-1.21-2.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/blueman-1.21-2.fc11
Comment 18 Fedora Update System 2009-11-12 14:53:20 EST
blueman-1.21-2.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/blueman-1.21-2.fc12
Comment 19 Bradley 2009-11-12 15:55:00 EST
Fixes the crash - thanks a lot for the quick response. Unfortunately the update breaks connecting to the iPhone entirely, but thats a separate bug...
Comment 20 Dave Malcolm 2009-11-14 08:00:14 EST
(In reply to comment #19)
> Fixes the crash - thanks a lot for the quick response. Unfortunately the update
> breaks connecting to the iPhone entirely, but thats a separate bug...  
(for posterity: the iPhone connectivity regression was bug 537089)
Comment 21 Fedora Update System 2009-11-16 02:28:48 EST
blueman-1.21-2.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update blueman'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2009-11519
Comment 22 Fedora Update System 2009-11-16 02:34:46 EST
blueman-1.21-2.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update blueman'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-11594
Comment 23 Fedora Update System 2009-11-20 00:37:13 EST
blueman-1.21-2.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 24 Dave Malcolm 2009-12-01 11:01:01 EST
*** Bug 542995 has been marked as a duplicate of this bug. ***
Comment 25 Fedora Update System 2009-12-22 14:55:07 EST
blueman-1.21-2.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 26 Dave Malcolm 2010-03-23 12:07:23 EDT
*** Bug 576116 has been marked as a duplicate of this bug. ***