Skip to content

Commit 5a65e5e

Browse files
committed
test coverage for segfault [d4ba38d00d06ebba]
1 parent ff263b4 commit 5a65e5e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/thread.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,37 @@ proc ThreadReap {} {
3333
llength [thread::names]
3434
}
3535

36+
test thread-1.11 {no segfault on 2nd interpreter, bug [d4ba38d00d06ebba]} -body {
37+
# This behavior needs to be covered in a separate shell, because it doesn't expect
38+
# any other thread invocation before 2nd interpreter gets the thread::id (TSD),
39+
# but test-suite calls thread::id command (tcltest, all.tcl and thread.test):
40+
set fd [open [list |[info nameofexecutable] << [string map [list {$$load} [tcltest::loadScript]] {
41+
$$load; package require thread
42+
interp create ci
43+
set l {}
44+
ci eval {$$load; package require thread; thread::id}
45+
thread::send -async [thread::id] {lappend l ev-1}; update
46+
interp delete ci
47+
thread::send -async [thread::id] {lappend l ev-2}; update; # no SF here
48+
puts $l
49+
}] 2>@stderr] r]
50+
gets $fd
51+
} -cleanup {
52+
catch { close $fd }
53+
} -result {ev-1 ev-2}
54+
55+
test thread-1.12 {no events in 2nd interpreter, bug [d4ba38d00d06ebba]} -setup {
56+
interp create ci
57+
} -body {
58+
set l {}
59+
thread::send -async [thread::id] {lappend l ev-1}; update
60+
ci eval {package require tcltest; tcltest::loadTestedCommands; package require thread}
61+
thread::send -async [thread::id] {lappend l ev-2}; update
62+
set l
63+
} -cleanup {
64+
interp delete ci
65+
} -result {ev-1 ev-2}
66+
3667
test thread-2.0 {no global thread command} {
3768
info commands thread
3869
} {}

0 commit comments

Comments
 (0)