Tcl Source Code

View Ticket
Login
Ticket UUID: b4637c4312a59ca57ef8148623f973a7493e950a
Title: upvar segfault for destroyed object
Type: Bug Created on: 2025-05-08 09:31:31
Submitter: ooa64_ua_fm Assigned to: dkf
Subsystem: 35. TclOO Package Severity: Severe
Priority: 5 Medium Last modified: 2026-11-01 20:39:55
Status: Closed Closed by: dkf
Resolution: Fixed Closed on: 2026-11-01 20:39:55
Version: 8.6.18, 9.0.5, 9.1.0
Description:
This script crashes tcl interpreter (segmentation fault on linux or silent crash on windows):
---
proc crash {varname} {
    upvar $varname V ;# <<<< crashes here !!!
}

oo::class create C {
    variable V
    method run {} {
        my destroy
        crash V
    }
}

C create c
c run
---

Trying on:
windows tcl 8.6.16, 9.0.2
linux tcl 8.6.12
https://onecompiler.com/tcl 8.6.14
User Comments:
serhiy.storchaka added on 2026-10-13 19:08:05:

Same cause as [28de60cef5]: after [my destroy] the namespace of the object is deleted, and resolving V for upvar in the method looked it up there. It also crashes with 8.6.17, 9.0 and 9.1.

Proposed fix in branch oo-destructor-deleted-namespace: the script returns normally, and V is a new unset variable. Test oo-3.14.


dkf added on 2026-11-01 17:42:58:

Confirming the crash with 9.1.0, and it looks like something that wants a backport fix to 9.0 too.

No plans to backport to 8.6, given the support status of that release line.


dkf added on 2026-11-01 20:38:45:

Fix applied to 9.0 onwards.


dkf added on 2026-11-01 20:39:55:

BTW, thanks for hunting this down, Serhiy.