Skip to content
Tcl Source Code View Ticket
Login

View Ticket

namespace ensemble subcommand name prefix matching and a subsequent error results in a segmentation fault

Closed / Fixedccc448a6bfd59cbdb2bd5cfd3392e386994883aaCreated 5 years agoUpdated 5 years ago
Descriptionwiki2021-09-01 21:32:18
When passed as a file to tclsh, the following script, with eva missing the final l, results in a segmentation fault:

    namespace eva n1 {error hello}

An alternate script that produces the same result is:

    namespace eval n1 {
        namespace ensemble create
        namespace export *
        proc p1 args {error hello}
    }
    namespace eva n1 {::n1 p1}

The reason is that TclSpellFix sets NULL as the first object pointer in iPtr->ensembleRewrite.sourceObjs and then later, in NRNamespaceEvalCmd, TclFetchEnsembleRoot copies a pointer to this array into framePtr->objv. Next, when an error occurs, TclLogCommandInfo accesses this array and trips on the NULL, causing the segmentation fault.

pooryorickwiki2021-09-01 23:14:19

Fixed in commit [a2e801a3d6c1675b].

jan.nijtmansplain2021-09-02 09:21:02
Is this fix going to be backported to 8.7 -> 8.6 too?
jan.nijtmanswiki2021-09-02 10:07:56

Windows build fails due to the the following warning, which is threated as an error in debug builds:

D:\a\tcl\tcl\win\..\generic\tclEnsemble.c(2247): error C2220: the following warning is treated as an error
D:\a\tcl\tcl\win\..\generic\tclEnsemble.c(2247): warning C4047: '=': 'Tcl_Obj *const *' differs in levels of indirection from 'Tcl_Obj *const '

pooryorickwiki2021-09-02 21:17:53

Warning silenced in [d49a1b03291b4cde].

pooryorickwiki2021-09-02 22:43:11

Fix merged to core-8-branch in [bd393417060a158f].

pooryorickwiki2021-09-02 23:05:08

Fix merged to core-8-6-branch in [da5128637598b0f1].

jan.nijtmanswiki2021-09-03 07:54:53

Thanks! Closing

Log in (anonymous is fine) to add a comment.