# Possible diagnosis for issue 520, hier\_block2::disconnect\_all() misbehavior

**URL:** <https://www.ruby-forum.com/t/possible-diagnosis-for-issue-520-hier-block2-disconnect-all-misbehavior/236244>\
**Category:** GNU Radio\
**Created:** [August 17, 2013, 6:35pm UTC](https://www.ruby-forum.com/t/possible-diagnosis-for-issue-520-hier-block2-disconnect-all-misbehavior/236244 "2013-08-17T18:35:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [August 17, 2013, 6:35pm UTC](https://www.ruby-forum.com/t/possible-diagnosis-for-issue-520-hier-block2-disconnect-all-misbehavior/236244/1 "2013-08-17T18:35:09Z")

</div>

(I would have sent this as a comment on the issue tracker, but creating  
an account didn’t seem to give me permission to comment.)

I’ve been using GNU Radio (strictly via Python) and met what seems to be  
the already-reported issue [http://gnuradio.org/redmine/issues/520](http://gnuradio.org/redmine/issues/520),  
where a hier\_block2 will misbehave after calling disconnect\_all().

Specifically, according to the exceptions seen from Python, it forgets  
that it has any inputs or outputs and rejects attempts to connect to  
them; for example, “output port 0 out of range for throttle(2)”  
resulting from self.connect(throttle, self).

I took a look at the code, and I found this suspicious bit in  
hier\_block2\_detail.cc:

void  
hier\_block2\_detail::disconnect\_all()  
{  
d\_fg-\>clear();  
d\_blocks.clear();  
d\_inputs.clear();  
d\_outputs.clear();  
}

I have very little C++ experience, but if I understand correctly, the  
last two lines will cause the input and output port vectors to have  
length 0, which would explain the observed behavior. There does not seem  
to be any code which increases the size of the vectors again.

If this is so, the fix would be to reset each element to the unset value  
individually rather than removing elements. (I don’t know how to write  
that in idiomatic C++.)

I hope someone who has a working GNU Radio development environment (I’ve  
tried and failed, which is an unrelated problem) can try this fix.

–  
Kevin R. [http://switchb.org/kpreid/](http://switchb.org/kpreid/)

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [August 19, 2013, 6:17pm UTC](https://www.ruby-forum.com/t/possible-diagnosis-for-issue-520-hier-block2-disconnect-all-misbehavior/236244/2 "2013-08-19T18:17:55Z")

</div>

On Sat, Aug 17, 2013 at 12:33 PM, Kevin R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (I would have sent this as a comment on the issue tracker, but creating an  
> account didn’t seem to give me permission to comment.)

See this in the FAQ for posting:

[http://gnuradio.org/redmine/projects/gnuradio/wiki/FAQ#How-can-I-post-on-this-wiki-use-the-bug-tracker](http://gnuradio.org/redmine/projects/gnuradio/wiki/FAQ#How-can-I-post-on-this-wiki-use-the-bug-tracker)

I have added you to the GNU Radio project so you can post now.

> ```
> d_blocks.clear();
> 
> ```
> 
> –  
> Kevin R. [http://switchb.org/kpreid/](http://switchb.org/kpreid/)

This is really good information. Johnathan and I will look it over and  
discuss it.

Thanks!

–  
Tom  
Visit us at GRCon13 Oct. 1 - 4

> **[GNU Radio Conference 2013 — Rondeau Research](http://www.trondeau.com/gnu-radio-conference-2013)**

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [August 25, 2013, 7:51pm UTC](https://www.ruby-forum.com/t/possible-diagnosis-for-issue-520-hier-block2-disconnect-all-misbehavior/236244/3 "2013-08-25T19:51:16Z")

</div>

On Mon, Aug 19, 2013 at 9:16 AM, Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > }  
> > I hope someone who has a working GNU Radio development environment (I’ve  
> > tried and failed, which is an unrelated problem) can try this fix.
> 
> This is really good information. Johnathan and I will look it over and  
> discuss it.

This issue was fixed this morning. The two lines in question were  
indeed  
the fault; instead of clearing the vectors, they should have been  
recreated  
with empty contents as is done in the constructor to initialize them.

Thanks.
