|
From: | Jim Melton |
Subject: | RE: Re: Re: Why does this dump core? |
Date: | Fri, 17 Sep 2021 16:03:39 +0000 |
For the sake of the archives, the issue was virtual inheritance. See
https://www.cprogramming.com/tutorial/virtual_inheritance.html One thing to be aware of is that if either
transmitter or receiver attempted to invoke the storable constructor in their initialization lists, that call will be completely skipped when constructing a
radio object! Be careful, as this could cause a subtle bug! Because the interface class virtually inherited from
gr::block, then the impl must explicitly invoke the gr::block ctor with the desired arguments. Because it didn’t, the default
gr::block ctor was invoked. That ctor demonstrably instantiates an object where
message_port_register_out dumps core. Whether that is desired behavior or not is another matter. In my case, it was failure to properly initialize a virtual base class. --- Jim Melton From: Jim Melton
I can’t explain it, but I found what’s wrong. My failing Test class that derives from gr::block called the default ctor. That’s bad. If
instead, Test calls the “real” ctor, with io_signature and everything, it works. Note that the example that derives from gr::sync_block does call the “real” ctor; if I use the default gr::sync_block ctor, it still fails. I didn’t think I was calling the default ctor, but apparently I was. The interface class: class CYBERRADIO_API vita_udp_rx : virtual public gr::block { … protected: using gr::block::block; // "inherit" base class ctor }; Since this interface doesn’t really do anything, I thought I could just pass-through to the gr::block constructor(s). The impl class: class vita_udp_rx_impl : public vita_udp_rx { using Base = vita_udp_rx; … }; The impl ctor: vita_udp_rx_impl::vita_udp_rx_impl(Cfg const& cfg) : Base("vita_udp_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(1, 1, sizeof(gr_complex))), … { … } What this
should do is pass through to the gr::block constructor. But it doesn’t appear to do so. If instead, I write vita_udp_rx_impl::vita_udp_rx_impl(Cfg const& cfg) : gr::block("vita_udp_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(1, 1, sizeof(gr_complex))), … { … } Then it works. ---
Jim Melton From: Discuss-gnuradio <discuss-gnuradio-bounces+jim.melton=sncorp.com@gnu.org>
On Behalf Of Jeff Long The Message Strobe block: gr-blocks/include/gnuradio/blocks/message_strobe.h gr-blocks/lib/message_strobe_impl.h gr-blocks/lib/message_strobe_impl.cc looks like the simplest builtin block that has a message out port. It subclasses gr::block, so that should work. Instantiating gr::block directly, and on the stack, is not something I've tried. Your longer bit of code shows you're using sptrs. On Wed, Sep 15, 2021 at 5:57 PM Jim Melton <jim.melton@sncorp.com> wrote:
CONFIDENTIALITY NOTICE - SNC EMAIL: This email and any attachments are confidential, may contain proprietary, protected, or export controlled information, and are intended for the use of the intended recipients only. Any review, reliance, distribution, disclosure, or forwarding of this email and/or attachments outside of Sierra Nevada Corporation (SNC) without express written approval of the sender, except to the extent required to further properly approved SNC business purposes, is strictly prohibited. If you are not the intended recipient of this email, please notify the sender immediately, and delete all copies without reading, printing, or saving in any manner. --- Thank You.
|
[Prev in Thread] | Current Thread | [Next in Thread] |