discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Possibly incorrect gr_msg_queue.delete_head_nowai


From: Isdren Gineer
Subject: Re: [Discuss-gnuradio] Possibly incorrect gr_msg_queue.delete_head_nowait() implementation
Date: Thu, 3 Oct 2013 15:52:25 -0700

This should have been obvious to me earlier. The problem is that 0 _is_ being return and the assertion that 'px != 0' (correctly) fails. Perhaps the use of gr.msg_queue.delete_head_nowait() should be deprecated and the equivalent behavior achieved by checking if gr.msg_queue.count() == 0 prior to calling gr.msg_queue.delete_head().


On Thu, Oct 3, 2013 at 3:33 PM, Isdren Gineer <address@hidden> wrote:
Of course, if 0 is returned, msg2_out would not be an message instance, but it would be possible to check if msg2_out == 0 before trying to call any instance methods.


On Thu, Oct 3, 2013 at 3:27 PM, Isdren Gineer <address@hidden> wrote:
According to the documentation comments, gr_msg_queue::delete_head_nowait() should return 0 if no message is available. The current implementation, however, results in a core dump.

For example, when executed in a script, the eleven lines:

#/usr/bin/env python
from gnuradio import gr
q = gr.msg_queue(1)
msg1_in = gr.message_from_string('msg1 payload')
q.insert_tail(msg1_in)
msg1_out = q.delete_head_nowait()
print 'msg1_out object: %s' % str(msg1_out)
print 'msg1_out value: %s' % msg1_out.to_string()
msg2_out = q.delete_head_nowait()
print 'msg2_out object: %s' % str(msg2_out)
print 'msg2_out value: %s' % msg2_out.to_string()

generate the output:

msg1_out object: <gnuradio.gr.gnuradio_core_runtime.gr_message_sptr; proxy of <Swig Object of type 'gr_message_sptr *' at 0x16529c0> >
msg1_out value: msg1 payload
msg2_out object: <gnuradio.gr.gnuradio_core_runtime.gr_message_sptr; proxy of <Swig Object of type 'gr_message_sptr *' at 0x16529f0> >
python: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr< <template-parameter-1-1> >::operator->() const [with T = gr_message]: Assertion `px != 0' failed.
Aborted (core dumped)

All of the other gr.msg_queue swig'd functions also cause a core dump.

The definition of gr_msg_queue:delete_head_nowait() includes the block:

  if ((m = d_head) == 0){
    //return 0;
    return gr_message_sptr();
  }

I believe the correct implementation should the 'return 0' line uncommented and the 'return gr_message_sprt()' removed.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]