diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2016-01-27 11:24:19 +0100 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2016-01-27 13:09:34 -0800 |
commit | 11973c64437683cc99c48eae9eb4db8234f1ac42 (patch) | |
tree | 54059f5e91babef20f114ed81629c82a0d4a0244 /gnuradio-runtime/include/gnuradio/sptr_magic.h | |
parent | 6e482c5bb6bf49f000f6b8d35a1ca84127e38c46 (diff) |
gnuradio-runtime: Fix sptr magic when exception thrown in hier2 constructor
Fixes #528
Previously, if an exception is thrown in constructor of a hier_block2
subclass, then :
- The hier_block2 base destructor _will_ be called
- The actual object is destroyed
- But the initial sptr would be left in the static map and point to
an invalid object
- Whatever connection() were made might have an invalid sptr ref as well
So to fix this:
- In the hier_block2 destructor, we explicitely disconnect() everything
- In the base hier_block2 destructor, we call a new 'cancel sptr' method
that will check if this object is still in the static map or not
- If it's not: Then this is a legit call to the destructor by shared_ptr
and everything is fine
- If it's: Then there was an isue and the object is already being
destroyed and we need to make sure shared_ptr doesn't try to do it
again. We do this using a special 'disarmable' custom deleter.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/sptr_magic.h')
-rw-r--r-- | gnuradio-runtime/include/gnuradio/sptr_magic.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gnuradio-runtime/include/gnuradio/sptr_magic.h b/gnuradio-runtime/include/gnuradio/sptr_magic.h index 898edc87fd..6deb3062ae 100644 --- a/gnuradio-runtime/include/gnuradio/sptr_magic.h +++ b/gnuradio-runtime/include/gnuradio/sptr_magic.h @@ -38,6 +38,7 @@ namespace gnuradio { public: static boost::shared_ptr<gr::basic_block> fetch_initial_sptr(gr::basic_block *p); static void create_and_stash_initial_sptr(gr::hier_block2 *p); + static void cancel_initial_sptr(gr::hier_block2 *p); }; }; |