Forum: GNU Radio Reconfiguring a hier_block2 without locking the top block

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
992d7640b9396bb5e8baf989281b59c0?d=identicon&s=25 Kieran Brownlees (Guest)
on 2009-03-17 03:48
(Received via mailing list)
Hello all,

Is the code designed so you can .lock() a individual hier_block2 and
reconfigure it without having to lock the overall top_block? IF you do
have
to lock the top block, why?

The code below causes a seg fault on my 3.1.3 and 3.2 installations.

Sample code (http://pastebin.com/d413db7f7):

from gnuradio import gr

class h_block(gr.hier_block2):
    def __init__(self):
        gr.hier_block2.__init__(self, "hello", gr.io_signature(0, 0, 0),
gr.io_signature(0, 0, 0))
        self.source = gr.null_source(gr.sizeof_float)
        self.sink = gr.null_sink(gr.sizeof_float)
        self.connect(self.source, self.sink)

    def reconfigure(self):
        self.lock()
        self.disconnect(self.source, self.sink)
        self.source = gr.null_source(gr.sizeof_float)
        self.connect(self.source, self.sink)
        self.unlock()

class top_block(gr.top_block):
    def __init__(self):
        gr.top_block.__init__(self)
        self.h_block = h_block()
        self.connect(self.h_block)

if __name__ == '__main__':
    app = top_block()
    app.start()
    print "Reconfiguring h_block"
    app.h_block.reconfigure()
    app.stop()

Thank you,
Kieran
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-03-17 20:02
(Received via mailing list)
On Tue, Mar 17, 2009 at 03:47:54PM +1300, Kieran Brownlees wrote:
> Hello all,
>
> Is the code designed so you can .lock() a individual hier_block2 and
> reconfigure it without having to lock the overall top_block? IF you do have
> to lock the top block, why?
>

You can lock/unlock on anything derived from from hier_block2 or
top_block.


FWIW, your code works for me using the trunk as of r10628.
That is, it prints "Reconfiguring h_block", and then hangs.
(The hang is a different bug that will be addressed soon.)


> The code below causes a seg fault on my 3.1.3 and 3.2 installations.

If it printed anything before dying, can you please post that?
Can you generate a backtrace from the segfault using gdb?

Eric
992d7640b9396bb5e8baf989281b59c0?d=identicon&s=25 Kieran Brownlees (Guest)
on 2009-03-17 22:13
(Received via mailing list)
On Wed, Mar 18, 2009 at 8:01 AM, Eric Blossom <eb@comsec.com> wrote:

>
> FWIW, your code works for me using the trunk as of r10628.
> That is, it prints "Reconfiguring h_block", and then hangs.
> (The hang is a different bug that will be addressed soon.)
>

Is the hang coming from the lock? Since it seems to be crashing once it
gets
into an infinite loop while locking.


If it printed anything before dying, can you please post that?
> Can you generate a backtrace from the segfault using gdb?


(Ignore the file name - I added the "Locking" to see where in the
sequence
it was crashing)
sdrts@sdrts:~/test$ python multiple_top_block_test.py
Reconfiguring h_block
Locking
Segmentation fault
sdrts@sdrts:~/test$

And backtrace from gdb: (3.1.3 but same thing happens at the same point
in
my 3.2 installation)

>>> app.h_block.reconfigure()

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7d748c0 (LWP 30961)]
gr_hier_block2::lock (this=0xa012a40) at gr_hier_block2.cc:98
98      gr_hier_block2::lock()
Current language:  auto; currently c++
(gdb) backtrace
#0  gr_hier_block2::lock (this=0xa012a40) at gr_hier_block2.cc:98
#1  0xb7afa023 in gr_hier_block2_detail::lock (this=<value optimized
out>)
at gr_hier_block2_detail.cc:369
#2  0xb7af93f0 in gr_hier_block2::lock (this=0xa012a40) at
gr_hier_block2.cc:100
#3  0xb7afa023 in gr_hier_block2_detail::lock (this=<value optimized
out>)
at gr_hier_block2_detail.cc:369
#4  0xb7af93f0 in gr_hier_block2::lock (this=0xa012a40) at
gr_hier_block2.cc:100
#5  0xb7afa023 in gr_hier_block2_detail::lock (this=<value optimized
out>)
at gr_hier_block2_detail.cc:369
#6  0xb7af93f0 in gr_hier_block2::lock (this=0xa012a40) at
gr_hier_block2.cc:100
#7  0xb7afa023 in gr_hier_block2_detail::lock (this=<value optimized
out>)
at gr_hier_block2_detail.cc:369
#8  0xb7af93f0 in gr_hier_block2::lock (this=0xa012a40) at
gr_hier_block2.cc:100

This goes on for a looong time (I stopped after 30,000 lines).

Thank you,
Kieran
This topic is locked and can not be replied to.