Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-01-27
18:15 • Closed ticket [2531577fff]: Redefining object constructor after error causes SI... artifact: 61d64ea2c0 user: dkf
18:00 • Ticket [2531577fff]: 4 changes artifact: e074b09a70 user: dkf
2009-01-24
21:33 • Ticket [2531577fff]: 1 change artifact: 1472e0af3d user: dkf
03:01 • Ticket [2531577fff]: 1 change artifact: bb4b8578e3 user: msofer
02:50 • Ticket [2531577fff]: 1 change artifact: 0c9e532226 user: msofer
02:38 • Ticket [2531577fff]: 4 changes artifact: 838f1cdf9d user: andygoth
2009-01-23
19:37 • New ticket [2531577fff]. artifact: cb1bcfe770 user: andygoth

Redefining object constructor after error causes SIGSEGV

Closed / Fixed2531577fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2009-01-23 19:37:35
oo::class create foo {constructor {} {error x}}
foo new
oo::define foo {constructor {} {}}
foo new

The first invocation of [foo new] fails with error "x".  The second invocation of [foo new] crashes the Tcl interpreter.

Observed using Pat Thoyts's tclkit-gui-86b1.exe (x86 Windows) and using a self-compiled Tcl 8.6b1 on Linux.  Here's the backtrace on the latter:

#0  0x031e22e8 in ?? ()
#1  0x00b90d44 in TclOOInvokeContext (clientData=0x998b070, interp=0x998a8e0,
    objc=2, objv=0x998b04c)
    at /home/users/td26063/build/tcl8.6b1/generic/tclOOCall.c:303
#2  0x00b8d681 in TclNRNewObjectInstance (interp=0x998a8e0, cls=0x99c6728,
    nameStr=0x0, nsNameStr=0x0, objc=2, objv=0x998b04c, skip=2,
    objectPtr=0x99bd1c4)
    at /home/users/td26063/build/tcl8.6b1/generic/tclOO.c:1394
#3  0x00b8f346 in TclOO_Class_New (clientData=0x0, interp=0x998a8e0,
    context=0x998b058, objc=2, objv=0x998b04c)
    at /home/users/td26063/build/tcl8.6b1/generic/tclOOBasic.c:238
#4  0x00b90d44 in TclOOInvokeContext (clientData=0x998b058, interp=0x998a8e0,
    objc=2, objv=0x998b04c)
    at /home/users/td26063/build/tcl8.6b1/generic/tclOOCall.c:303
#5  0x00b8e86f in TclOOObjectCmdCore (oPtr=0x99c6540, interp=0x998a8e0,
    objc=2, objv=0x998b04c, flags=1, startCls=0x0)
    at /home/users/td26063/build/tcl8.6b1/generic/tclOO.c:2110
#6  0x00b8e4c7 in PublicNRObjectCmd (clientData=0x99c6540, interp=0x998a8e0,
    objc=2, objv=0x998b04c)
    at /home/users/td26063/build/tcl8.6b1/generic/tclOO.c:1951
#7  0x00ab0f8c in NRRunObjProc (data=0x99adbcc, interp=0x998a8e0, result=0)
    at /home/users/td26063/build/tcl8.6b1/generic/tclBasic.c:4303
#8  0x00ab0d7d in TclNRRunCallbacks (interp=0x998a8e0, result=0,
    rootPtr=0x999b680, tebcCall=1)
    at /home/users/td26063/build/tcl8.6b1/generic/tclBasic.c:4241
#9  0x00b08b76 in TclExecuteByteCode (interp=0x998a8e0, codePtr=0x99c6bd0)
    at /home/users/td26063/build/tcl8.6b1/generic/tclExecute.c:2813
#10 0x00ab1020 in NRCallTEBC (data=0x99a9484, interp=0x998a8e0, result=0)
    at /home/users/td26063/build/tcl8.6b1/generic/tclBasic.c:4325
#11 0x00ab0d7d in TclNRRunCallbacks (interp=0x998a8e0, result=0, rootPtr=0x0,
    tebcCall=0) at /home/users/td26063/build/tcl8.6b1/generic/tclBasic.c:4241
#12 0x00ab2c9f in TclEvalObjEx (interp=0x998a8e0, objPtr=0x999e548,
    flags=131072, invoker=0x0, word=0)
    at /home/users/td26063/build/tcl8.6b1/generic/tclBasic.c:5717
#13 0x00ab2c40 in Tcl_EvalObjEx (interp=0x998a8e0, objPtr=0x31e22e8,
    flags=131072) at /home/users/td26063/build/tcl8.6b1/generic/tclBasic.c:5698
#14 0x00b1dcb7 in Tcl_RecordAndEvalObj (interp=0x998a8e0, cmdPtr=0x99adc58,
    flags=131072)
    at /home/users/td26063/build/tcl8.6b1/generic/tclHistory.c:161
#15 0x00b429ae in Tcl_Main (argc=-1, argv=0xbfe56b38,
    appInitProc=0x804868b <Tcl_AppInit>)
    at /home/users/td26063/build/tcl8.6b1/generic/tclMain.c:468
#16 0x0804867e in main (argc=1, argv=0xbfe56b34)
    at /home/users/td26063/build/tcl8.6b1/unix/tclAppInit.c:87
andygothplain2009-01-24 02:38:26
Oops, sorry about the bug title.  It should have been "Redefining object constructor after error causes SIGSEGV".
msofer Ticket [2531577fff]: 1 change [History diff]2009-01-24 02:50:08
msofer Ticket [2531577fff]: 1 change [History diff]2009-01-24 03:01:34
dkf Ticket [2531577fff]: 1 change [History diff]2009-01-24 21:33:44
dkfplain2009-01-27 18:00:35
The error isn't necessary. The problem also occurs if you create and delete an object.

(It's caused by a failure to clear a cache upon setting a constructor. Destructors were similarly broken.)
dkfplain2009-01-27 18:15:21
allow_comments - 1

Fixed in HEAD and in the stand-alone TclOO code.
Log in (anonymous is fine) to add a comment.