Ticket #199 (defect)

Opened 1 year ago

Last modified 11 months ago

usrp_spectrum_sense.py segfaults on some machines.

Status: new

Reported by: eb Assigned to: nobody
Priority: normal Milestone: to-be-decided
Component: gnuradio-examples Version: 3.1svn
Keywords: Cc:

Worked OK for me on Fedora 7 on Opteron. Worked OK for me on Ubuntu 7.04 on Pentium M. Segfaulted on 32-bit machine running SuSE 10.1

Looks like it's correlated with the Python version. 2.4 fails, 2.5 works.

hypothesis: there's a per-thread Python init routine that we may need to be calling in addition to using PyGILState_Ensure/Release.

[eb@cyan usrp]$ ./usrp_spectrum_sense.py 400M 450M
audio: using audio_alsa
Using RX d'board A: TV Rx
gain = 57.5
Segmentation fault
(gdb) c
Continuing.
[New Thread -1229718624 (LWP 3310)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1229718624 (LWP 3310)]
0xb7eb792a in sem_post@GLIBC_2.0 () from /lib/libpthread.so.0
(gdb) thread apply all bt

Thread 2 (Thread -1229718624 (LWP 3310)):
#0  0xb7eb792a in sem_post@GLIBC_2.0 () from /lib/libpthread.so.0
#1  0xb7f62a0d in PyThread_release_lock () from /usr/lib/libpython2.4.so.1.0
#2  0xb7f3bf40 in PyEval_ReleaseLock () from /usr/lib/libpython2.4.so.1.0
#3  0xb7f5b802 in PyThreadState_DeleteCurrent ()
   from /usr/lib/libpython2.4.so.1.0
#4  0xb7f5bc2d in PyGILState_Release () from /usr/lib/libpython2.4.so.1.0
#5  0xb76db7a3 in gr_py_feval_dd::calleval ()
   from /usr/local/lib/python2.4/site-packages/gnuradio/gr/_gnuradio_swig_py_general.so
#6  0xb79e9277 in gr_bin_statistics_f::enter_tune_delay (this=0x818dd38)
    at gr_bin_statistics_f.cc:77
#7  0xb79e9455 in gr_bin_statistics_f::work (this=0x818dd38, noutput_items=14, 
    input_items=@0xb6b3f280, output_items=@0xb6b3f274)
    at gr_bin_statistics_f.cc:109
#8  0xb7a9df1a in gr_sync_block::general_work (this=0x818dd38, 
    noutput_items=14, ninput_items=@0xb6b3f28c, input_items=@0xb6b3f280, 
    output_items=@0xb6b3f274) at gr_sync_block.cc:64
#9  0xb7a9c142 in gr_single_threaded_scheduler::main_loop (this=0x82aa868)
    at gr_single_threaded_scheduler.cc:338
#10 0xb7a9d1bd in gr_single_threaded_scheduler::run (this=0x82aa868)
    at gr_single_threaded_scheduler.cc:86
#11 0xb7a9b204 in gr_scheduler_thread::run_undetached (this=0x824a698, arg=0x0)
    at gr_scheduler_thread.cc:98
#12 0xb7fc3f67 in omni_thread_wrapper (ptr=0x824a698) at posix.cc:450
#13 0xb7eb234b in start_thread () from /lib/libpthread.so.0
#14 0xb7d3165e in clone () from /lib/libc.so.6

Thread 1 (Thread -1211685200 (LWP 3305)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7eb57e6 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0xb7fc35bb in omni_condition::wait (this=0x818dca4) at posix.cc:152
#3  0xb7a99da6 in gr_msg_queue::delete_head (this=0x818dc88)
    at gr_msg_queue.cc:81
#4  0xb7b3ef0e in gr_py_msg_queue__delete_head ()
   from /usr/local/lib/python2.4/site-packages/gnuradio/gr/_gnuradio_swig_py_runtime.so
#5  0xb7b3f188 in _wrap_gr_py_msg_queue__delete_head ()
   from /usr/local/lib/python2.4/site-packages/gnuradio/gr/_gnuradio_swig_py_runtime.so
#6  0xb7f08cdd in PyCFunction_Call () from /usr/lib/libpython2.4.so.1.0
#7  0xb7ee0e17 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
#8  0xb7f3fc15 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#9  0xb7f42115 in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
#10 0xb7f406c6 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#11 0xb7f417be in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#12 0xb7f42115 in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
#13 0xb7f42193 in PyEval_EvalCode () from /usr/lib/libpython2.4.so.1.0
#14 0xb7f5c988 in Py_CompileString () from /usr/lib/libpython2.4.so.1.0
#15 0xb7f5e058 in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.4.so.1.0
#16 0xb7f5e73a in PyRun_AnyFileExFlags () from /usr/lib/libpython2.4.so.1.0
#17 0xb7f64c0f in Py_Main () from /usr/lib/libpython2.4.so.1.0
#18 0x080485e2 in main ()
#0  0xb7eb792a in sem_post@GLIBC_2.0 () from /lib/libpthread.so.0
(gdb) 

Change History

11/06/07 16:09:00: Modified by eb

  • owner changed from eb to nobody.

11/07/07 12:45:25: Modified by eb

  • description changed.

11/19/07 12:09:26: Modified by jcorgan

Changing the qa_bin_statistics.py program to use the new top block code causes the same failure to occur when using Python 2.5:

(gdb) set args qa_bin_statistics.py
(gdb) run
Starting program: /usr/bin/python qa_bin_statistics.py
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 47427854391008 (LWP 4216)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 1082132816 (LWP 4219)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1082132816 (LWP 4219)]
0x00002b22a7aaa4f5 in sem_post () from /lib/libpthread.so.0
(gdb) thread apply all bt

Thread 2 (Thread 1082132816 (LWP 4219)):
#0  0x00002b22a7aaa4f5 in sem_post () from /lib/libpthread.so.0
#1  0x00000000004b2c79 in PyThread_release_lock ()
#2  0x00002b22a9c751c3 in gr_py_feval_dd::calleval () from /usr/local/lib/python2.5/site-packages/gnuradio/gr/_gnuradio_swig_py_general.so
#3  0x00002b22a8a2213d in gr_bin_statistics_f::enter_tune_delay (this=0x7f5ff0) at gr_bin_statistics_f.cc:77
#4  0x00002b22a8a22328 in gr_bin_statistics_f::work (this=0x7f5ff0, noutput_items=4, input_items=@0x1, output_items=@0x2b22a7aaa507)
    at gr_bin_statistics_f.cc:131
#5  0x00002b22a8ad0671 in gr_sync_block::general_work (this=0x0, noutput_items=1, ninput_items=<value optimized out>, input_items=@0x0, 
    output_items=@0x2b22a7aaa507) at gr_sync_block.cc:64
#6  0x00002b22a8aceb4e in gr_single_threaded_scheduler::main_loop (this=0xebe570) at gr_single_threaded_scheduler.cc:338
#7  0x00002b22a8acdc79 in gr_scheduler_thread::run_undetached (this=0x75a4c0, arg=<value optimized out>) at gr_scheduler_thread.cc:98
#8  0x00002b22a946b6ad in omni_thread_wrapper (ptr=<value optimized out>) at posix.cc:450
#9  0x00002b22a7aa4317 in start_thread () from /lib/libpthread.so.0
#10 0x00002b22a8415d5d in clone () from /lib/libc.so.6
#11 0x0000000000000000 in ?? ()

Thread 1 (Thread 47427854391008 (LWP 4216)):
#0  0x00002b22a7aa56c6 in pthread_join () from /lib/libpthread.so.0
#1  0x00002b22a946c0f7 in omni_thread::join (this=0x75a4c0, status=0x7fff03225618) at posix.cc:643
#2  0x00002b22a8ad1cab in gr_top_block_impl::wait (this=<value optimized out>) at gr_top_block_impl.cc:161
#3  0x00002b22a86c1d61 in top_block_run_unlocked () from /usr/local/lib/python2.5/site-packages/gnuradio/gr/_gnuradio_swig_py_runtime.so
#4  0x00002b22a86ca7f5 in _wrap_top_block_run_unlocked () from /usr/local/lib/python2.5/site-packages/gnuradio/gr/_gnuradio_swig_py_runtime.so
#5  0x0000000000417e53 in PyObject_Call ()
#6  0x0000000000486997 in PyEval_EvalFrameEx ()
#7  0x0000000000489d60 in PyEval_EvalCodeEx ()
#8  0x0000000000487f32 in PyEval_EvalFrameEx ()
#9  0x0000000000488c3e in PyEval_EvalFrameEx ()
#10 0x0000000000488c3e in PyEval_EvalFrameEx ()
#11 0x0000000000489d60 in PyEval_EvalCodeEx ()
#12 0x00000000004d431c in ?? ()
#13 0x0000000000417e53 in PyObject_Call ()
#14 0x0000000000486997 in PyEval_EvalFrameEx ()
#15 0x0000000000489d60 in PyEval_EvalCodeEx ()
#16 0x00000000004d437e in ?? ()
#17 0x0000000000417e53 in PyObject_Call ()
#18 0x000000000041e5ed in ?? ()
#19 0x0000000000417e53 in PyObject_Call ()
#20 0x000000000045a79a in ?? ()