Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-05-13
03:29 • Closed ticket [1960724fff]: crash calling a method plus 6 other changes artifact: 06e235999b user: pertronic
2008-05-12
19:55 • Pending ticket [1960724fff]. artifact: b7446258b5 user: dkf
2008-05-11
23:48 • Ticket [1960724fff]: 4 changes artifact: 643199ef79 user: dkf
2008-05-10
15:17 • Ticket [1960724fff]: 5 changes artifact: 10ebad1d56 user: dkf
2008-05-09
04:25 • New ticket [1960724fff]. artifact: fa646db1e4 user: pertronic

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.