Index: xotcl/ChangeLog =================================================================== diff -u -r47c4c8f68826b6e7b4b9fa38e65bd77f281d7dbf -r09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db --- xotcl/ChangeLog (.../ChangeLog) (revision 47c4c8f68826b6e7b4b9fa38e65bd77f281d7dbf) +++ xotcl/ChangeLog (.../ChangeLog) (revision 09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db) @@ -1,4 +1,8 @@ 2004-07-27 Gustaf.Neumann@wu-wien.ac.at + * yet another fixed access to freed memory + (thanks to Zoran for his help with Purify ) + +2004-07-26 Gustaf.Neumann@wu-wien.ac.at * fixed bug in filters in connection with instmixin; inactive tcl callstack frame was dereferenced. This fixed as well a potential uplevel bug Index: xotcl/apps/actiweb/Counter4.xotcl =================================================================== diff -u -rf7894d9be99a8da3a04218abcdb9bd46b6d625c8 -r09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db --- xotcl/apps/actiweb/Counter4.xotcl (.../Counter4.xotcl) (revision f7894d9be99a8da3a04218abcdb9bd46b6d625c8) +++ xotcl/apps/actiweb/Counter4.xotcl (.../Counter4.xotcl) (revision 09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db) @@ -1,5 +1,5 @@ #!../../src/xotclsh -# $Id: Counter4.xotcl,v 1.1 2004/05/23 22:50:39 neumann Exp $ +# $Id: Counter4.xotcl,v 1.2 2004/07/27 21:39:46 neumann Exp $ array set opts {-pkgdir .}; array set opts $argv lappend auto_path $opts(-pkgdir) @@ -16,7 +16,7 @@ my incr count } -### Definiere a Counter subclass for persistent counting +### Define a Counter subclass for persistent counting Class PersistentCounter -superclass Counter PersistentCounter instproc init args { ;### Constructor next ;### call superclasses' init @@ -30,7 +30,7 @@ PersistentCounter c2 -### Definiere a proxy class, that handles HTML decoration +### Define a proxy class, that handles HTML decoration ### HtmlProxy forwards all unknown calls to "realSubject" Class HtmlProxyCounter -superclass HtmlProxy HtmlProxyCounter instproc init args { ;### Constructor Index: xotcl/generic/xotcl.c =================================================================== diff -u -r47c4c8f68826b6e7b4b9fa38e65bd77f281d7dbf -r09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db --- xotcl/generic/xotcl.c (.../xotcl.c) (revision 47c4c8f68826b6e7b4b9fa38e65bd77f281d7dbf) +++ xotcl/generic/xotcl.c (.../xotcl.c) (revision 09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db) @@ -1,4 +1,4 @@ -/* $Id: xotcl.c,v 1.14 2004/07/27 09:35:18 neumann Exp $ +/* $Id: xotcl.c,v 1.15 2004/07/27 21:39:46 neumann Exp $ * * XOTcl - Extended OTcl * @@ -388,6 +388,7 @@ #if !defined(NDEBUG) memset(obj, 0, sizeof(XOTclObject)); #endif + /*fprintf(stderr,"CKFREE obj %p\n",obj);*/ ckfree((char *) obj); } } @@ -3767,6 +3768,8 @@ assert(obj); RUNTIME_STATE(in)->callIsDestroy = 0; + /*fprintf(stderr,"callProcCheck: setting callIsDestroy = 0, m=%s obj=%p\n", + methodName, obj);*/ /* fprintf(stderr,"*** callProcCheck: cmd = %p\n",cmd); @@ -4002,10 +4005,12 @@ Tcl_Obj *cmdName = obj->cmdName; XOTclRuntimeState *rst = RUNTIME_STATE(in); XOTclCallStack *cs = &rst->cs; + int isdestroy = (objv[1] == XOTclGlobalObjects[DESTROY]); #ifdef AUTOVARS int isNext; #endif + assert(objc>0); methodName = callMethod = ObjStr(objv[1]); @@ -4149,14 +4154,17 @@ fprintf(stderr,"obj %p mixinStackPushed %d mixinStack %p\n", obj, mixinStackPushed, obj->mixinStack); #endif - /* - fprintf(stderr, "obj freed? %p destroy %p self %p %s %d %d\n",obj, + + /* + if (!isdestroy && !rst->callIsDestroy ) + fprintf(stderr, "obj freed? %p destroy %p self %p %s %d %d (%d)\n",obj, cs->top->destroyedCmd, cs->top->self, ObjStr(objv[1]), rst->callIsDestroy, - (obj->flags & XOTCL_DESTROY_CALLED)!=0 + (obj->flags & XOTCL_DESTROY_CALLED)!=0,isdestroy ); */ - if (obj && !rst->callIsDestroy && + + if (!isdestroy && !rst->callIsDestroy && !(obj->flags & XOTCL_DESTROY_CALLED)) { if (mixinStackPushed && obj->mixinStack) MixinStackPop(obj); @@ -4226,7 +4234,7 @@ DECR_REF_COUNT(nonPosArg->nonPosArgs); DECR_REF_COUNT(nonPosArg->ordinaryArgs); MEM_COUNT_FREE("nonPosArg",nonPosArg); - ckfree ((char*) nonPosArg); + ckfree((char*) nonPosArg); Tcl_DeleteHashEntry(hPtr); } } @@ -4391,7 +4399,7 @@ hPtr = Tcl_CreateHashEntry(nonPosArgsTable, ObjStr(ov[1]), &nw); if (nw) { MEM_COUNT_ALLOC("nonPosArg",nonPosArg); - nonPosArg = (XOTclNonPosArgs*) ckalloc(sizeof(XOTclNonPosArgs)); + nonPosArg = (XOTclNonPosArgs*)ckalloc(sizeof(XOTclNonPosArgs)); nonPosArg->nonPosArgs = nonPosArgsObj; nonPosArg->ordinaryArgs = objv[3]; INCR_REF_COUNT(objv[3]); @@ -5722,6 +5730,7 @@ unsigned length; char *fn; + /*fprintf(stderr, "CKALLOC Object %p %s\n", obj, name);*/ #if defined(XOTCLOBJ_TRACE) fprintf(stderr, "CKALLOC Object %p %s\n", obj, name); #endif @@ -5983,6 +5992,8 @@ unsigned length; XOTclObject *obj = (XOTclObject*)cl; + /*fprintf(stderr, "CKALLOC Class %p %s\n", cl, name);*/ + memset(cl, 0, sizeof(XOTclClass)); MEM_COUNT_ALLOC("XOTclObject/XOTclClass",cl); /* @@ -8122,7 +8133,7 @@ */ delobj->flags |= XOTCL_DESTROY_CALLED; RUNTIME_STATE(in)->callIsDestroy = 1; - + /*fprintf(stderr,"instDestroy: setting callIsDestroy = 1\n");*/ if (RUNTIME_STATE(in)->exitHandlerDestroyRound != XOTCL_EXITHANDLER_ON_SOFT_DESTROY) { CallStackDestroyObject(in, delobj); Index: xotcl/tests/testx.xotcl =================================================================== diff -u -r47c4c8f68826b6e7b4b9fa38e65bd77f281d7dbf -r09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db --- xotcl/tests/testx.xotcl (.../testx.xotcl) (revision 47c4c8f68826b6e7b4b9fa38e65bd77f281d7dbf) +++ xotcl/tests/testx.xotcl (.../testx.xotcl) (revision 09f6e8e5fc0163ad71fcf113a5b5dfc63da4a5db) @@ -1,4 +1,4 @@ -#$Id: testx.xotcl,v 1.13 2004/07/27 09:35:18 neumann Exp $ +#$Id: testx.xotcl,v 1.14 2004/07/27 21:39:46 neumann Exp $ package require XOTcl namespace import -force xotcl::* @@ -3489,6 +3489,69 @@ puts [nonposargs run] } +TestX copymove2 +copymove2 proc run {{n 10}} { + # Composite + Class Composite -superclass Class + Composite instproc addop {op} { + my instvar ops + set ops($op) $op + } + Composite instproc compositeFilter args { + set m [self calledproc] + set c [lindex [self filterreg] 0] + set r [next] + + if {[$c exists ops($m)]} { + foreach child [my info children] { + eval [self]::$child $m $args + } + } + return $r + } + + Composite AbstractNode + AbstractNode abstract instproc iterate v + AbstractNode addop iterate + for {set i 0} {$i < $n} {incr i} { + # + # class copy + # + foreach filters {{} compositeFilter} { + Composite instfilter $filters + AbstractNode instfilter $filters + Object commands + Class Commands -superclass AbstractNode + Class Command -superclass Commands + Command instproc init args { + my instvar label + set label [self] + next + } + Command instproc setlabel {{arg ""}} { + my instvar label + if {$arg == ""} { + set label + } else { + set label $arg + } + } + Command instproc setproc {value} { + my instvar src + set src $value + } + # prototypes + Command commands::cellcmd + commands::cellcmd copy toto + } + } + return "PASSED [self]" +} + + +puts [copymove2 run] +#exit + puts "XOTcl - Test" puts "Time used: [time {TestX run} 1]"