Menu

#293 Destructor silently fails to delete class object

cvs-HEAD
open
nobody
None
8
2024-06-12
2024-06-12
No

Hello,

I am using tclsh 8.6 and itcl 4.2.1. My machine's OS is CentOS Linux release 7.9.2009 (Core).
I have noticed a bug in itcl destructor. A destructor with tcl syntax error can silently pass, but the object is not deleted. I created an itcl::local instance of my_class (a class with a syntax error in destructor) inside a procedure body. First procedure call passes with the error silented (which is already quite bad). Another call fails because of already existing object with the specified name in the current namespace. At that point I can't remove the object manually, since interpreter claims that it is currently being deleted.

Check the following example:

package require itcl

itcl::class my_class {
destructor {
puts "my_class destructor start"
dict for {k v} {
puts "syntax error on purpose"
}
}
}
proc my_proc {} {
itcl::local my_class 123
}
puts "Error in destructor is silented"
my_proc
puts "'123' exists in current namespace"
my_proc
itcl::delete object 123 ;# -> can't delete an object while it is being destructed

Discussion


Log in to post a comment.

MongoDB Logo MongoDB