Overview
| Artifact ID: | 62a622aa8910c27ae3b5f8edc01c23d09ce672a0554a0e13d123806ab2808f9a |
|---|---|
| Ticket: | 0b809cd3fc8b6e5e19cd8a9a91357e425472cd69
SIGSEGV on shutdown with TclOO, coroutines, namespaces, and -DPURIFY |
| User & Date: | andy on 2024-12-04 00:22:06 |
Changes
- icomment:
I came up with a script that crashes Tcl without using namespaces, interpreters, or `-DPURIFY`, making this a more serious issue: ``` oo::class create class oo::define class method yield {} {yield} coroutine coro [class new] yield trace add command coro delete {apply {{args} {lrepeat 0}}} class destroy rename coro {} ``` Despite the class being destroyed, the coroutine remains suspended within the method, until the coroutine itself is forcibly destroyed, at which point the bogus error message is generated. However, the trace on coroutine command destruction forces an allocation to occur between the free and the use-after-free, stomping on the freed class struct, thereby causing the error message generation to crash. This crash can happen within a safe interpreter: ``` interp create -safe child child eval { ... the above script ... } ``` By the way, I apologize for the formatting error in the prior comment, no way to edit it now. If the Valgrind listing is messed up, just narrow your browser window until it wraps nicely. - login: "andy"
- mimetype: "text/x-markdown"
- username: "andy"