<html>
<head>
<meta content="text/html; charset=GB2312" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">于 2013年02月23日 11:34, Xiang Zhai 写道:<br>
</div>
<blockquote cite="mid:512838E3.1050503@gmail.com" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=GB2312">
Hi PulseAudio developers, <br>
<br>
I am developing PulseAudio Python Binding in C based on
pa_threaded_mainloop to handle pa_context_subscribe callback.<br>
<br>
For example, when received PA_SUBSCRIPTION_EVENT_SINK
PA_SUBSCRIPTION_EVENT_CHANGE event, I used PyEval_CallFunction to
call Python (pygtk.py) callback.<br>
Then pygtk.py testcase throw segfault, gdb DEBUG shown as below:<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
[Switching to Thread 0x7fffebb3f700 (LWP 10150)]<br>
0x00000000004e9f20 in PyObject_Call ()<br>
(gdb) bt<br>
#0 0x00000000004e9f20 in PyObject_Call ()<br>
#1 0x00000000004ea396 in PyEval_CallObjectWithKeywords ()<br>
#2 0x0000000000478a99 in PyEval_CallFunction ()<br>
#3 0x00007fffed1969b6 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#4 0x00007fffecd45693 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#5 0x00007fffecd45a03 in pa_pdispatch_run () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#6 0x00007fffed18cbdd in ?? () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#7 0x00007fffecd4a2a9 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#8 0x00007fffed19fa1e in pa_mainloop_dispatch () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#9 0x00007fffed19fde5 in pa_mainloop_iterate () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#10 0x00007fffed19fe90 in pa_mainloop_run () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#11 0x00007fffed1ae30f in ?? () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#12 0x00007fffecd57d18 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#13 0x00007ffff7bc4e9a in start_thread (arg=0x7fffebb3f700) at
pthread_create.c:308<br>
#14 0x00007ffff69b3cbd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112<br>
#15 0x0000000000000000 in ?? ()<br>
<br>
I tried to add PyGILState_Ensure() & PyGILState_Release()
around PyEval_CallFunction() for locking/unlocking, it still throw
another segfault shown as below:<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
[Switching to Thread 0x7fffebb3f700 (LWP 10362)]<br>
sem_post () at
../nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S:34<br>
(gdb) bt<br>
#0 sem_post () at
../nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S:34<br>
#1 0x00000000004d456e in PyGILState_Release ()<br>
#2 0x00007fffed1969b6 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#3 0x00007fffecd45693 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#4 0x00007fffecd45a03 in pa_pdispatch_run () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#5 0x00007fffed18cbdd in ?? () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#6 0x00007fffecd4a2a9 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#7 0x00007fffed19fa1e in pa_mainloop_dispatch () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#8 0x00007fffed19fde5 in pa_mainloop_iterate () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#9 0x00007fffed19fe90 in pa_mainloop_run () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#10 0x00007fffed1ae30f in ?? () from
/usr/lib/x86_64-linux-gnu/libpulse.so.0<br>
#11 0x00007fffecd57d18 in ?? () from
/usr/lib/x86_64-linux-gnu/libpulsecommon-1.1.so<br>
#12 0x00007ffff7bc4e9a in start_thread (arg=0x7fffebb3f700) at
pthread_create.c:308<br>
#13 0x00007ffff69b3cbd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112<br>
#14 0x0000000000000000 in ?? ()<br>
<br>
However, the console.py (non-gtk & no g_main_loop) testcase
worked happily without segfault!<br>
<br>
The source code and testcase host on github
<meta http-equiv="content-type" content="text/html;
charset=GB2312">
<a moz-do-not-send="true"
href="https://github.com/xiangzhai/pypulseaudio">https://github.com/xiangzhai/pypulseaudio</a>
please someone give me advice, thanks a lot!<br>
<br>
Xiang Zhai<br>
</blockquote>
Fixed
<meta http-equiv="content-type" content="text/html; charset=GB2312">
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=61328">https://bugs.freedesktop.org/show_bug.cgi?id=61328</a><br>
<br>
I will give my sincere thanks to Tanu Kaskinen :)<br>
</body>
</html>