Menu

#1330 Tcl objects not deleted on program exit

None
closed-fixed
nobody
tcl (60) c++ (2)
5
2022-01-31
2013-07-20
'sood
No

With SWIG (2.0, wrapping with the -tcl and -c++ flags) wrapped object code in tclsh (8.5)...

I have a wrapped class A. On creation it generates a thread that does some background work. On destruction it joins with the spawned thread and dies a happy object.

#!/usr/bin/env tclsh
A a
a -delete ; # or rename a ""
exit

On the other hand, death without notice results in violent throes:

#!/usr/bin/env tclsh
A a
exit ; # <-- There's a segfault here; 'a' never got the memo to clean up

I'm inclined to say this is a bug on SWIG's end due to this behavior not being mentioned in the 2.0 docs in the last bit of section 37.3.6 or in section 37.3.7. At the very least, I think the docs should mention this.

Discussion

  • 'sood

    'sood - 2013-07-20

    Woop - forgot to specify minor version number. 2.0.9.

     
  • Olly Betts

    Olly Betts - 2022-01-31
    • status: open --> closed-fixed
    • Group: -->
     
  • Olly Betts

    Olly Betts - 2022-01-31

    I'm going to commit the following to address this - it'll be in SWIG 4.2.0:

    --- a/Doc/Manual/Tcl.html
    +++ b/Doc/Manual/Tcl.html
    @@ -1227,7 +1227,15 @@ _108fea88_p_Bar
    
     <p>
     Finally, to destroy objects created from Tcl, you can either let the object
    -name go out of scope or you can explicitly delete the object.  For example:
    +name go out of scope or you can explicitly delete the object as shown below.
    +Objects won't get automatically destroyed when the Tcl program exits, so if
    +it's important that the C++ destructor is called for a class you'll need to
    +make sure that you explicitly do this for objects of that class before program
    +exit.
    +</p>
    +
    +<p>
    +For example:
     </p>
    
     <div class="code">
    
     

Log in to post a comment.

MongoDB Logo MongoDB