<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - PulseAudio Python Binding PyEval_CallFunction segfault in pa_mainloop_dispatch based on pa_threaded_mainloop"
href="https://bugs.freedesktop.org/show_bug.cgi?id=61328">61328</a>
</td>
</tr>
<tr>
<th>CC</th>
<td>lennart@poettering.net
</td>
</tr>
<tr>
<th>Assignee</th>
<td>pulseaudio-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Summary</th>
<td>PulseAudio Python Binding PyEval_CallFunction segfault in pa_mainloop_dispatch based on pa_threaded_mainloop
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>pulseaudio-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Reporter</th>
<td>xiangzhai83@gmail.com
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Component</th>
<td>clients
</td>
</tr>
<tr>
<th>Product</th>
<td>PulseAudio
</td>
</tr></table>
<p>
<div>
<pre>Hi PulseAudio developers,
I am developing PulseAudio Python Binding in C based on pa_threaded_mainloop to
handle pa_context_subscribe callback.
For example, when received PA_SUBSCRIPTION_EVENT_SINK
PA_SUBSCRIPTION_EVENT_CHANGE event, I used PyEval_CallFunction to call Python
(pygtk.py) callback.
Then pygtk.py testcase throw segfault, gdb DEBUG shown as below:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffebb3f700 (LWP 10150)]
0x00000000004e9f20 in PyObject_Call ()
(gdb) bt
#0 0x00000000004e9f20 in PyObject_Call ()
#1 0x00000000004ea396 in PyEval_CallObjectWithKeywords ()
#2 0x0000000000478a99 in PyEval_CallFunction ()
#3 0x00007fffed1969b6 in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#4 0x00007fffecd45693 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#5 0x00007fffecd45a03 in pa_pdispatch_run () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#6 0x00007fffed18cbdd in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#7 0x00007fffecd4a2a9 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#8 0x00007fffed19fa1e in pa_mainloop_dispatch () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0
#9 0x00007fffed19fde5 in pa_mainloop_iterate () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0
#10 0x00007fffed19fe90 in pa_mainloop_run () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0
#11 0x00007fffed1ae30f in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#12 0x00007fffecd57d18 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#13 0x00007ffff7bc4e9a in start_thread (arg=0x7fffebb3f700) at
pthread_create.c:308
#14 0x00007ffff69b3cbd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#15 0x0000000000000000 in ?? ()
I tried to add PyGILState_Ensure() & PyGILState_Release() around
PyEval_CallFunction() for locking/unlocking, it still throw another segfault
shown as below:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffebb3f700 (LWP 10362)]
sem_post () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S:34
(gdb) bt
#0 sem_post () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S:34
#1 0x00000000004d456e in PyGILState_Release ()
#2 0x00007fffed1969b6 in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#3 0x00007fffecd45693 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#4 0x00007fffecd45a03 in pa_pdispatch_run () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#5 0x00007fffed18cbdd in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#6 0x00007fffecd4a2a9 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#7 0x00007fffed19fa1e in pa_mainloop_dispatch () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0
#8 0x00007fffed19fde5 in pa_mainloop_iterate () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0
#9 0x00007fffed19fe90 in pa_mainloop_run () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0
#10 0x00007fffed1ae30f in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#11 0x00007fffecd57d18 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so
#12 0x00007ffff7bc4e9a in start_thread (arg=0x7fffebb3f700) at
pthread_create.c:308
#13 0x00007ffff69b3cbd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#14 0x0000000000000000 in ?? ()
However, the console.py (non-gtk & no g_main_loop) testcase worked happily
without segfault, and I added cgtk.c (Gtk+-2.0 based testcase in C) worked
correctly!
The source code and testcase host on github
<a href="https://github.com/xiangzhai/pypulseaudio">https://github.com/xiangzhai/pypulseaudio</a> please someone give me advice, thanks
a lot!</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>