upvar segfault for destroyed object
Closed / Fixedb4637c4312a59ca57ef8148623f973a7493e950aCreated 2 years agoUpdated 32 days ago
Descriptionplain2025-05-08 09:31:31
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
Referenced by4
f3f08274f7Fix [28de60cef5] and [b4637c4312] check-in2026-11-01 20:36:04298d1d97d5Fix [28de60cef5] and [b4637c4312] check-in2026-11-01 20:30:55eed1c88593Backport of Fix [b4637c4312]: [upvar] to an object variable after the object was destroyed in its method crashed. check-in2026-11-01 20:11:51de6527681fFix [b4637c4312]: [upvar] to an object variable after the object was destroyed in its method crashed. Same cause as [28de60cef5]; add a test. check-in2026-10-13 19:06:40
serhiy.storchakawiki2026-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.
dkfmarkdown2026-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.
dkfmarkdown2026-11-01 20:38:45
Fix applied to 9.0 onwards.
dkfmarkdown2026-11-01 20:39:55
BTW, thanks for hunting this down, Serhiy.
Log in (anonymous is fine) to add a comment.