Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2021-06-21
21:36 • Closed ticket [688fcc7082]: trace on imported alias deletes alias and then calls... artifact: fccf1a8427 user: pooryorick
21:36 • Ticket [688fcc7082]: 3 changes artifact: 4a21a16411 user: pooryorick
2021-05-20
15:53 • Ticket [688fcc7082]: 3 changes artifact: 6399055756 user: jan.nijtmans
12:35
Merge 8.6, except [688fcc7082] because it gives a merge conflict check-in: 113ceaa417 user: jan.nijtmans tags: core-8-branch
2021-05-18
15:10 • Ticket [688fcc7082] trace on imported alias deletes alias and then calls import ... artifact: 39f066f591 user: jan.nijtmans
14:30 • Ticket [688fcc7082]: 3 changes artifact: c9b3384c3c user: pooryorick
08:47 • Open ticket [688fcc7082]. artifact: 44c7f28a54 user: jan.nijtmans
06:03
Additional test for [688fcc7082fa99a4], imported command trace memory error. check-in: 0c70f77653 user: pooryorick tags: core-8-branch
2021-05-17
21:35 • Ticket [688fcc7082] trace on imported alias deletes alias and then calls import ... artifact: c39fd56136 user: pooryorick
21:30
Fix for [688fcc7082fa99a4], trace on imported alias deletes alias and then calls import and triggers... check-in: e45d054ba4 user: pooryorick tags: core-8-6-branch
21:29
Additional test for [688fcc7082fa99a4]. check-in: 81f260feaf user: pooryorick tags: core-8-6-branch
2020-08-29
09:03 • Closed ticket [688fcc7082]: trace on imported alias deletes alias and then calls... artifact: 950417fab7 user: pooryorick
2020-08-17
10:21 • Ticket [688fcc7082]: 3 changes artifact: 89922f1a21 user: pooryorick
2020-08-16
10:06 • Ticket [688fcc7082]: 3 changes artifact: d6a8917c2d user: pooryorick
10:04
Fix for [688fcc7082fa], memory error during deletion of imported routine. check-in: 037c0ff27f user: pooryorick tags: core-8-branch
09:52 • New ticket [688fcc7082] trace on imported alias deletes alias and then calls imp... artifact: d8e474a137 user: pooryorick

trace on imported alias deletes alias and then calls import and triggers memory error

Closed / Fixed688fcc7082fa99a4bd934098c58666841e9e0b0aCreated 6 years agoUpdated 5 years ago
Descriptionwiki2020-08-16 09:52:56
In Tcl built with -DPURIFY and --enable-symbols, the following script results in a segmentation fault:

variable res {}
namespace eval ns1 {
    namespace export *
    proc p1 {} {
        return success
    }
    interp alias {} [namespace current]::p2 {} [namespace current]::p1
}


namespace eval ns2 {
    namespace import [namespace parent]::ns1::p2
}

proc ondelete {oldname newname op} {
    variable res
    catch {
        $oldname
    } cres
    set res [string match {invalid command name*ns1::p1*} $cres]
}
trace add command  ns2::p2 delete ondelete
namespace delete ns1

The issue is that the delete trace on the imported routine deletes the namespace of the underlying routine, resulting in the deletion of both the underlying routine and the alias, but then the imported command is called, and its ImportedCmdData structure still holds a reference to the now-deleted Alias structure.

Referenced by1
pooryorickwiki2020-08-16 10:06:37

Fixed in [037c0ff27fd5d0a2] by modifying Tcl_DeleteCommandFromToken() so that it deletes any imports of the routine before deleting the routine itself.

pooryorick Ticket [688fcc7082]: 3 changes [History diff]2020-08-17 10:21:42
pooryorick Closed ticket [688fcc7082]. [History diff]2020-08-29 09:03:37
pooryorickwiki2021-05-17 21:35:32

Fix applied to core-8-6-branch in [e45d054ba46ee5c2].

jan.nijtmanswiki2021-05-18 08:47:19

Re-opening, because this fix broke the build: https://github.com/tcltk/tcl/actions/runs/852459210

pooryorickwiki2021-05-18 14:30:25

Fixed again in [3b0e92b198b86975].

jan.nijtmanswiki2021-05-18 15:10:26

This - indeed - looks OK now, but it's only applied to 8.6 yet. Will 8.7 and 9.0 follow soon? Then it can be closed.

jan.nijtmanswiki2021-05-20 15:53:22

@pooryorick: Noting that commit [3b0e92b198b86975] was on core-8-branch, is this bug now fixed on all branches?

pooryorickwiki2021-06-21 21:36:11

This fix was committed to core-8-branch in [037c0ff27fd5d0a2] and also made its way to trunk via merge of core-8-branch. [3b0e92b198b86975] is unrelated and shouldn't have been noted in this report.

pooryorick Closed ticket [688fcc7082]. [History diff]2021-06-21 21:36:36
Log in (anonymous is fine) to add a comment.