[USRP-users] Segmentation Fault when using UHD

Hunter DeJarnette hunter.dejarnette at gmail.com
Wed Apr 29 09:24:54 EDT 2015


I've got an application where I need to frequently reconfigure a GNURadio
flow graph.  I found that after stopping, disconnecting, and then
restarting a usrp source block I will randomly get a segmentation fault.  I
will get the segmentation fault after anywhere from 50 - 600 stop/start
cycles.  I'm running Ubuntu 12.04 and have compiled UHD 3.8.3-r1 from
source.  A copy of the stack trace, and the flow graph that I used to
generate the segmentation fault can be found below.  Any help would be much
appreciated.

Stack trace:
Core was generated by `python ./test_two_channel.py'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007f50fffa63ee in _mm_loadu_si128 (__P=0x0) at
/usr/lib/gcc/x86_64-linux-gnu/4.6/include/emmintrin.h:685
685      return (__m128i) __builtin_ia32_loaddqu ((char const *)__P);
(gdb) bt
#0  0x00007f50fffa63ee in _mm_loadu_si128 (__P=0x0) at
/usr/lib/gcc/x86_64-linux-gnu/4.6/include/emmintrin.h:685
#1  __convert_sc16_item32_le_1_fc32_1_PRIORITY_SIMD::operator()
(this=0x7f50e4000a50, inputs=..., outputs=..., nsamps=512)
    at
/home/hunter/src/uhd-release_003_008_003-1/host/lib/convert/sse2_sc16_to_fc32.cpp:58
#2  0x00007f51002b3eec in conv (num=512, out=..., in=...,
this=0x7f50e4000a50) at
/home/hunter/src/uhd-release_003_008_003-1/host/include/uhd/convert.hpp:44
#3  uhd::transport::sph::recv_packet_handler::converter_thread_task
(this=0x7f50e4000cd8, index=1)
    at
/home/hunter/src/uhd-release_003_008_003-1/host/lib/usrp/usrp1/../../transport/super_recv_packet_handler.hpp:685
#4  0x00007f51002d70b7 in boost::_mfi::mf1<void,
uhd::transport::sph::recv_packet_handler, unsigned long>::operator()
(this=0x7f50e4001c70, p=0x7f50e4000cd8, a1=1)
    at /usr/include/boost/bind/mem_fn_template.hpp:165
#5  0x00007f51002d49bd in
boost::_bi::list2<boost::_bi::value<uhd::transport::sph::recv_packet_handler*>,
boost::_bi::value<unsigned long> >::operator()<boost::_mfi::mf1<void,
uhd::transport::sph::recv_packet_handler, unsigned long>,
boost::_bi::list0> (this=0x7f50e4001c80, f=..., a=...) at
/usr/include/boost/bind/bind.hpp:313
#6  0x00007f51002d1be5 in boost::_bi::bind_t<void, boost::_mfi::mf1<void,
uhd::transport::sph::recv_packet_handler, unsigned long>,
boost::_bi::list2<boost::_bi::value<uhd::transport::sph::recv_packet_handler*>,
boost::_bi::value<unsigned long> > >::operator() (this=0x7f50e4001c70) at
/usr/include/boost/bind/bind_template.hpp:20
#7  0x00007f51002ce3bc in
boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void,
boost::_mfi::mf1<void, uhd::transport::sph::recv_packet_handler, unsigned
long>,
boost::_bi::list2<boost::_bi::value<uhd::transport::sph::recv_packet_handler*>,
boost::_bi::value<unsigned long> > >, void>::invoke (function_obj_ptr=...)
at /usr/include/boost/function/function_template.hpp:153
#8  0x00007f51002be338 in boost::function0<void>::operator()
(this=0x7f50e4001c40) at
/usr/include/boost/function/function_template.hpp:760
#9  0x00007f51004a7134 in task_impl::task_loop(boost::function<void ()>
const&) (this=0x7f50e4001050, task_fcn=...) at
/home/hunter/src/uhd-release_003_008_003-1/host/lib/utils/tasks.cpp:53
#10 0x00007f51004ab563 in boost::_mfi::mf1<void, task_impl,
boost::function<void ()> const&>::operator()(task_impl*,
boost::function<void ()> const&) const (this=0x7f50e4001c28,
p=0x7f50e4001050, a1=...)
    at /usr/include/boost/bind/mem_fn_template.hpp:165
#11 0x00007f51004ab3f5 in boost::_bi::list2<boost::_bi::value<task_impl*>,
boost::_bi::value<boost::function<void ()> >
>::operator()<boost::_mfi::mf1<void, task_impl, boost::function<void ()>
const&>, boost::_bi::list0>(boost::_bi::type<void>, boost::_mfi::mf1<void,
task_impl, boost::function<void ()> const&>&, boost::_bi::list0&, int)
(this=0x7f50e4001c38, f=..., a=...)
    at /usr/include/boost/bind/bind.hpp:313
#12 0x00007f51004ab313 in boost::_bi::bind_t<void, boost::_mfi::mf1<void,
task_impl, boost::function<void ()> const&>,
boost::_bi::list2<boost::_bi::value<task_impl*>,
boost::_bi::value<boost::function<void ()> > > >::operator()()
(this=0x7f50e4001c28) at /usr/include/boost/bind/bind_template.hpp:20
#13 0x00007f51004ab170 in
boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf1<void,
task_impl, boost::function<void ()> const&>,
boost::_bi::list2<boost::_bi::value<task_impl*>,
boost::_bi::value<boost::function<void ()> > > > >::run()
(this=0x7f50e4001aa0) at /usr/include/boost/thread/detail/thread.hpp:61
#14 0x00007f50febe8da9 in ?? () from /usr/lib/libboost_thread.so.1.48.0
#15 0x00007f51030dfe9a in start_thread () from
/lib/x86_64-linux-gnu/libpthread.so.0
#16 0x00007f5101eba38d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#17 0x0000000000000000 in ?? ()

I put together a simple flow graph to generate the segfault here.  I find
that after about 2-300 start/stops I get a segfault:
#!/usr/bin/env python
from gnuradio import uhd
from gnuradio import blocks
from gnuradio import gr
import time

class flowgraph(gr.top_block):
    def __init__(self):
        gr.top_block.__init__(self, "Test Seg Fault Graph")
        master_clock       = 51200000 / 2
        gain     = 20
        self.usrp_src = uhd.usrp_source(

device_addr="type=b200,master_clock_rate="+str(master_clock),
                stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(2)))
        self.usrp_src.set_samp_rate(2560000)
        rf_freq = 175000000
        tune_request = uhd.tune_request_t(rf_freq);
        tune_request.target_freq = rf_freq + 2000000
        tune_request.rf_freq_policy = uhd.tune_request_t.POLICY_MANUAL
        tune_request.rf_freq = rf_freq
        tune_request.dsp_freq_policy = uhd.tune_request_t.POLICY_AUTO
        self.usrp_src.set_center_freq(tune_request, 0)
        tune_request.target_freq = rf_freq - 2000000
        self.usrp_src.set_center_freq(tune_request, 1)
        self.usrp_src.set_gain(gain, 0)
        self.usrp_src.set_gain(gain, 1)
        self.usrp_src.set_subdev_spec("A:A A:B")
        self.nsink_0 = blocks.null_sink(gr.sizeof_gr_complex)
        self.nsink_1 = blocks.null_sink(gr.sizeof_gr_complex)

    def set_scan(self):
        self.connect((self.usrp_src, 0), self.nsink_0)
        self.connect((self.usrp_src, 1), self.nsink_1)

if __name__ == '__main__':
    count = 0
    tb = flowgraph()
    print "Configuring for flow graph!"
    tb.set_scan()
    print "Starting flow graph"
    tb.start()
    while True:
        time.sleep(0.5)
        count = count + 1
        print "Stopping Flowgraph " + str(count)
        tb.stop()
        tb.wait()
        print "Disconnecting Flowgraph"
        tb.disconnect_all()
        time.sleep(0.5)
        print "Re-configuring flow graph!"
        tb.set_scan()
        tb.start()
        print "Starting flow graph"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20150429/018eb653/attachment-0002.html>


More information about the USRP-users mailing list