crash calling a method
Closed / Works For Me1960724fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-05-09 04:25:08
# winXP, TclOO 0.2 Tcl 8.5.2
The following crashes on the "internal" call to copy.
The crash is sensitive to the number of object properties, e.g. if "my variable np_name" is removed from the constructor there is no crash.
package require TclOO
namespace import oo::*
class create A {
constructor {name} {
my variable np_name
set np_name $name
}
#
# make a deep copy
#
method copy {nm} {
set cpy [[info object class [self]] new $nm]
foreach var [info object vars [self]] {
my variable $var
set val [set $var]
if {[string match o_* $var]} {
set objs {}
foreach ref $val {
# call to "copy" crashes
lappend objs [$ref copy {}]
}
$cpy prop $var $objs
} else {
$cpy prop $var $val
}
}
return $cpy
}
method prop {name val} {
my variable $name
set $name $val
}
}
set o1 [A new {}]
set o2 [A new {}]
$o1 prop o_object $o2
$o1 copy aa
dkfplain2008-05-10 15:17:23
Logged In: YES user_id=79902 Originator: NO Code works for me with 0.3a0, but changes made so far probably shouldn't have cleared this problem.
dkfplain2008-05-11 23:48:42
Logged In: YES user_id=79902 Originator: NO I suspect that this is really a duplicate of artf1905797
dkfplain2008-05-12 19:55:07
Logged In: YES user_id=79902 Originator: NO Can't see anything wrong with HEAD even when using valgrind; hope it's fixed! (Let me know if the real code doesn't work... :-))
pertronicplain2008-05-13 03:29:12
Logged In: YES user_id=1532831 Originator: YES I have retested with a build of TclOO 0.3a0 from CVS HEAD (2008-05-12) and code now works for me also. Thanks
Log in (anonymous is fine) to add a comment.