Tuesday, February 1, 2011

GNU Radio bug #199

Update:

After much reading and testing, I simply added a call to PyEval_InitThreads() which got rid of the segmentation fault. As a bonus, my detector was working as well.



Well, I am pretty sure this is the same bug.

http://gnuradio.org/redmine/issues/show/199

It seems that once the GNU Radio teamed moved from Python 2.4 to 2.5 the problem went away...for them at least. I have been running the stock (64 bit) Fedora Python2.7 and got this same error. The system seg-faults when it trys to return from Python code back into C++ land. More specifically, on this line from ./gnuradio-3.3.0/gnuradio-core/src/lib/swig/gnuradio_swig_py_general.cc:

~ensure_py_gil_state() { PyGILState_Release(d_gstate); }

So for whatever reason, on my system, this line causes a segmentation fault. Now it is apparently working fine on unmodified GNU Radio examples (like gr_bin_statistics_f). I think it's time to notify the GNU Radio mailing list.

Turn's out this is a some-what common issue among C programs calling Python code. However, it doesn't appear to have a quick solution.


(gdb) c
Continuing.
[New Thread 0x7f4ec2ec5700 (LWP 2747)]
[New Thread 0x7f4ec26c4700 (LWP 2748)]
[New Thread 0x7f4ec1ec3700 (LWP 2749)]
[New Thread 0x7f4ec16c2700 (LWP 2750)]
[New Thread 0x7f4ec0ec1700 (LWP 2751)]
[New Thread 0x7f4eb3fff700 (LWP 2752)]
[New Thread 0x7f4eb37fe700 (LWP 2753)]
[New Thread 0x7f4eb2ffd700 (LWP 2754)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f4eb2ffd700 (LWP 2754)]
0x00000036b3e0db00 in sem_post () from /lib64/libpthread.so.0
(gdb) bt
#0  0x00000036b3e0db00 in sem_post () from /lib64/libpthread.so.0
#1  0x00000036c1317679 in PyThread_release_lock () from /usr/lib64/libpython2.7.so.1.0
#2  0x00007f4ec5aa7c1f in ~ensure_py_gil_state (this=0x1112df0, x=0)
    at gnuradio_swig_py_general.cc:5582
#3  gr_py_feval_dd::calleval (this=0x1112df0, x=0) at gnuradio_swig_py_general.cc:5593
#4  0x00007f4ec7112b60 in gr_noise_level_f::tune_window (this=0x10ff680, 
    target_freq=) at gr_noise_level_f.cc:97
#5  0x00007f4ec711353b in gr_noise_level_f::work (this=0x10ff680, noutput_items=7, 
    input_items=, output_items=)
    at gr_noise_level_f.cc:115
#6  0x00007f4ec71ae704 in gr_sync_block::general_work (this=0x10ff680, 
    noutput_items=, ninput_items=, 
    input_items=, output_items=) at gr_sync_block.cc:64
#7  0x00007f4ec7194cd4 in gr_block_executor::run_one_iteration (this=0x7f4eb2ffcd90)
    at gr_block_executor.cc:299
#8  0x00007f4ec71b2322 in gr_tpb_thread_body::gr_tpb_thread_body (this=0x7f4eb2ffcd90, block=...)
    at gr_tpb_thread_body.cc:49
#9  0x00007f4ec71aacd7 in operator() (function_obj_ptr=...) at gr_scheduler_tpb.cc:42
#10 operator() (function_obj_ptr=...)
    at /home/tja/Research/energy/detector/gnuradio-3.3.0/gruel/src/include/gruel/thread_body_wrapper.h:49
#11 boost::detail::function::void_function_obj_invoker0<gruel::thread_body_wrapper\, void>::invoke (function_obj_ptr=...) at /usr/include/boost/function/function_template.hpp:153
---Type  to continue, or q  to quit---
#12 0x00007f4ec6ddf4ef in operator() (this=)
    at /usr/include/boost/function/function_template.hpp:1013
#13 boost::detail::thread_data<boost::function0 >::run (this=)
    at /usr/include/boost/thread/detail/thread.hpp:61
#14 0x00007f4ec6baaa55 in thread_proxy () from /usr/lib64/libboost_thread-mt.so.1.44.0
#15 0x00000036b3e06d5b in start_thread () from /lib64/libpthread.so.0
#16 0x00000036b3ae4a7d in clone () from /lib64/libc.so.6
(gdb) quit

No comments:

Post a Comment