Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-20
21:11 • Ticket [a63f5a4fed] Safe interp gets the parent's -errorinfo and -errorstack... artifact: 60b4c1556c user: jan.nijtmans
2026-10-17
11:50 • Ticket [a63f5a4fed]: 3 changes artifact: 8157db24a5 user: serhiy.storchaka
2017-07-31
08:58 • Ticket [77f0dbc0f8] Wrong errorstack when using slave interp status still Op... artifact: 529ad7e9b9 user: danckaert
2017-07-27
14:46 • Ticket [77f0dbc0f8]: 3 changes artifact: 0e10381220 user: aspect
2017-07-26
12:00 • New ticket [77f0dbc0f8]. artifact: ed329d62c0 user: danckaert

Wrong errorstack when using slave interp

Open77f0dbc0f8234ace6f613a37831d33fa5407ad63Created 9 years agoUpdated 9 years ago
Descriptionwiki2017-07-26 12:00:05
When running the following code:
interp create slave
interp alias slave foo {} master_foo
proc master_foo {arg} {}
proc run_in_slave {s} {
    try {
        interp eval slave $s
    } on error {msg options} {
        puts $options
    }
}
catch {error "catched error"}
run_in_slave {foo}
The output is:
-errorstack {INNER {returnImm {catched error} {}} CALL {run_in_slave foo}} -errorcode {TCL WRONGARGS} -errorinfo {wrong # args: should be "foo arg"
    invoked from within
"foo"
    invoked from within
"interp eval slave $s"} -errorline 3 -code 1 -level 0
The INNER part int the errorstack refers to a previous error which had already been catched and should not be present anymore. Note that -errorinfo and -errorcode are correct however.
Referenced by2
  • 60b4c1556cTicket [a63f5a4fed] Safe interp gets the parent's -errorinfo and -errorstack through a failing alias status still Open with 6 other changes ticket2026-10-20 21:11:13
  • 8157db24a5Ticket [a63f5a4fed] Safe interp gets the parent's -errorinfo and -errorstack through a failing alias status still Open with 3 other changes ticket2026-10-17 11:50:46
aspectplain2017-07-27 14:46:03
This might come from Tcl_GetReturnOptions() not respecting resetErrorStack -
when it grabs the error stack from the master, the stale error stack gets
captured and sent into the slave.

https://core.tcl.tk/tcl/artifact/0947f3566cd3dbab?ln=1625

Replacing that line with the following seems to clear it up:

        if (iPtr->resetErrorStack) {
            Tcl_DictObjPut(NULL, options, keys[KEY_ERRORSTACK], Tcl_NewListObj(NULL, 0));
        } else {                                  
            Tcl_DictObjPut(NULL, options, keys[KEY_ERRORSTACK], iPtr->errorStack);
        }


.. but I don't understand why an alias back into the master is needed to
observe this; someone who knows better should check.
danckaertplain2017-07-31 08:58:15
With that change, the errorstack only contains CALL {run_in_slave foo}, but it should also contain an INNER {invokeStk1 foo} part, I think.
Log in (anonymous is fine) to add a comment.