Overview
| Artifact ID: | d76b6e56732bd01f8fbca46c52ecc9c62e604940a4a95362e1fd4d0cf3f58883 |
|---|---|
| Ticket: | 28de60cef5133f1bd5c07dadf4d1a6e1989878c4
Segfault in destructor using tsv::lock |
| User & Date: | cyan on 2020-02-16 10:44:05 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
I'm not sure this is the right place for this (maybe Thread?), but I've hit a segfault that involves the timing of an object's namespace deletion. I'm filing it against TclOO because I've hit a similar issue with a destructor implemented in c that doesn't involve tsv::lock, but the this version uses only Tcl script and standard packages distributed with Tcl releases: package require Thread oo::class create foo { variable thing constructor {} { set thing something } destructor { set local $thing rename [self] {} tsv::lock foo { puts "local: $local" ;# works puts "thing: $thing" ;# segfault } } } [foo new] destroy I admit that "rename [self] {}" in the destructor is silly, but it works if the tsv::lock isn't involved, and it's there to simulate the situation that occurs in the real code where I found this problem, where it is less silly. The crash happens on a call to Tcl_CreateHashEntry(TclVarTable(contextPtr->oPtr->namespacePtr) in ProcedureMethodCompiledVarConnect where contextPtr->oPtr->namespacePtr is NULL. In the possibly related case with a C method and destructor, the C method does a Tcl_DeleteCommandFromToken(interp, thisObjectCommand) on itself for the side effect of destroying the instance (if a more direct way of doing this exists please point me to it). Sometimes this does the expected thing and calls the destructor before returning from the Tcl_DeleteCommandFromToken, but under other circumstances (haven't found the relevant trigger yet, maybe NR context?) it chains to the destructor after the c method that called Tcl_DeleteCommandFromToken returns. But in that case (without calling the destructor yet) all the object metadata has been removed and the namespace deleted when Tcl_DeleteCommandFromToken returns, causing some difficulties for the destructor when it runs later. - foundin changed to: "8.6.*, 8.7a3"
- is_private changed to: "0"
- login: "cyan"
- priority changed to: "5 Medium"
- private_contact changed to: "54152f94cb1628c0c148b4b5708ace53216227b0"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "cyan"
- subsystem changed to: "10. Objects"
- title changed to: "Segfault in destructor using tsv::lock"
- type changed to: "Bug"