Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-05
17:17 • Closed ticket [20ca033dee]: Tcl 9.0.5 failing tests in valgrind plus 5 other... artifact: a5b79a0b69 user: jan.nijtmans
2026-11-04
15:27
Fix io-78.1 failing under valgrind [20ca033dee] check-in: a3c26a4561 user: dgp tags: core-9-0-branch
15:26 • Pending ticket [20ca033dee]: Tcl 9.0.5 failing tests in valgrind plus 5 othe... artifact: fc19d2f42d user: jan.nijtmans
15:23
Fix io-78.1 failing under valgrind [20ca033dee] check-in: f88b1e95c3 user: jan.nijtmans tags: trunk, main
2026-11-02
22:29 • Ticket [20ca033dee] Tcl 9.0.5 failing tests in valgrind status still Open wi... artifact: f82b6e9cbb user: serhiy.storchaka
22:20
Fix io-78.1 failing under valgrind [20ca033dee]: the child could exit before the parent wrote, so [p... closed check-in: 7e984069db user: serhiy.storchaka tags: io-test-pipe-reader-alive
18:52 • New ticket [20ca033dee] Tcl 9.0.5 failing tests in valgrind. artifact: f191efa6dc user: dgp

Tcl 9.0.5 failing tests in valgrind

Closed / Fixed20ca033deef14a85ee420ecb1c4111e25c88114bCreated 30 days agoUpdated 27 days ago
Descriptionplain2026-11-02 18:52:48
Several test failures appear in `make valgrind` on the sources
being prepped for a release of Tcl 9.0.5.  The same tests do
not fail in regular `make test` runs, so these are likely matters
of timing or race conditions.  I will not block the release over
these, but recording them as places to further improve the test
suite.  We have not had this number of such valgrind-only
failures before now.

==== io-78.1 writable event on pipe whose reader has exited FAILED
==== Contents of test case:

    fconfigure $f -blocking 0 -buffering full
    puts -nonewline $f [string repeat x 300000]
    catch {flush $f}
    after 100
    chan event $f writable [list set [namespace which -variable w] writable]
    set timer [after 5000 [list set [namespace which -variable w] timeout]]
    vwait [namespace which -variable w]
    after cancel $timer
    list $w [catch {close $f} msg] $msg

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error writing "file10": broken pipe
    while executing
"puts -nonewline $f [string repeat x 300000]"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== io-78.1 FAILED


==== iortrans-3.1 chan finalize, handler destruction has no effect on channel FAILED
==== Contents of test case:

    proc foo {args} {
        lappend ::res $args
        handle.initialize
        return
    }
    lappend res [set c [chan push [tempchan] foo]]
    rename foo {}
    lappend res [file channels file*]
    lappend res [file channels rt*]
    lappend res [catch {close $c} msg] $msg
    lappend res [file channels file*]
    lappend res [file channels rt*]

---- Result was:
{initialize rt15 {read write}} file9 {file9 file10} {} 1 {invalid command name "foo"} file10 {}
---- Result should have been (glob matching):
{initialize rt* {read write}} file* file* {} 1 {invalid command name "foo"} {} {}
==== iortrans-3.1 FAILED


==== process-3.1 empty subprocess list FAILED
==== Contents of test case:

    llength [tcl::process list]

---- Result was:
1
---- Result should have been (exact matching):
0
==== process-3.1 FAILED



==== process-3.2 empty subprocess status FAILED
==== Contents of test case:

    dict size [tcl::process status]

---- Result was:
1
---- Result should have been (exact matching):
0
==== process-3.2 FAILED

==== process-4.1 exec one child FAILED
==== Contents of test case:

    tcl::process autopurge 0
    set pid [exec [interpreter] $path(exit) 0 &]
    set list [tcl::process list]
    set statuses [tcl::process status -wait]
    set status [lindex [tcl::process status $pid] 1]
    expr {
           [llength $list] eq 1
        && [lindex $list 0] eq $pid
        && [dict size $statuses] eq 1
        && [dict get $statuses $pid] eq $status
        && $status eq 0
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== process-4.1 FAILED



==== process-4.2 exec two children in parallel FAILED
==== Contents of test case:

    tcl::process autopurge 0
    set pid1 [exec [interpreter] $path(exit) 0 &]
    set pid2 [exec [interpreter] $path(exit) 0 &]
    set list [tcl::process list]
    set statuses [tcl::process status -wait]
    set status1 [lindex [tcl::process status $pid1] 1]
    set status2 [lindex [tcl::process status $pid2] 1]
    expr {
           [llength $list] eq 2
        && [lsearch $list $pid1] >= 0
        && [lsearch $list $pid2] >= 0
        && [dict size $statuses] eq 2
        && [dict get $statuses $pid1] eq $status1
        && [dict get $statuses $pid2] eq $status2
        && $status1 eq 0
        && $status2 eq 0
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== process-4.2 FAILED


==== process-4.3 exec 3-stage pipe FAILED
==== Contents of test case:

    tcl::process autopurge 0
    set pids [exec  [interpreter] $path(exit) 0  | [interpreter] $path(exit) 0  | [interpreter] $path(exit) 0  &]
    lassign $pids pid1 pid2 pid3
    set list [tcl::process list]
    set statuses [tcl::process status -wait]
    set status1 [lindex [tcl::process status $pid1] 1]
    set status2 [lindex [tcl::process status $pid2] 1]
    set status3 [lindex [tcl::process status $pid3] 1]
    expr {
           [llength $pids] eq 3
        && [llength $list] eq 3
        && [lsearch $list $pid1] >= 0
        && [lsearch $list $pid2] >= 0
        && [lsearch $list $pid3] >= 0
        && [dict size $statuses] eq 3
        && [dict get $statuses $pid1] eq $status1
        && [dict get $statuses $pid2] eq $status2
        && [dict get $statuses $pid3] eq $status3
        && $status1 eq 0
        && $status2 eq 0
        && $status3 eq 0
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== process-4.3 FAILED


==== process-5.1 exec one child FAILED
==== Contents of test case:

    tcl::process autopurge 0
    set f [open "|\"[interpreter]\" \"$path(exit)\" 0"]
    set pid [pid $f]
    set list [tcl::process list]
    set statuses [tcl::process status -wait]
    set status [lindex [tcl::process status $pid] 1]
    expr {
           [llength $list] eq 1
        && [lindex $list 0] eq $pid
        && [dict size $statuses] eq 1
        && [dict get $statuses $pid] eq $status
        && $status eq 0
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== process-5.1 FAILED



==== process-5.2 exec two children in parallel FAILED
==== Contents of test case:

    tcl::process autopurge 0
    set f1 [open "|\"[interpreter]\" \"$path(exit)\" 0"]
    set f2 [open "|\"[interpreter]\" \"$path(exit)\" 0"]
    set pid1 [pid $f1]
    set pid2 [pid $f2]
    set list [tcl::process list]
    set statuses [tcl::process status -wait]
    set status1 [lindex [tcl::process status $pid1] 1]
    set status2 [lindex [tcl::process status $pid2] 1]
    expr {
           [llength $list] eq 2
        && [lsearch $list $pid1] >= 0
        && [lsearch $list $pid2] >= 0
        && [dict size $statuses] eq 2
        && [dict get $statuses $pid1] eq $status1
        && [dict get $statuses $pid2] eq $status2
        && $status1 eq 0
        && $status2 eq 0
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== process-5.2 FAILED

==== process-5.3 exec 3-stage pipe FAILED
==== Contents of test case:

    tcl::process autopurge 0
    set f [open "|
          \"[interpreter]\" \"$path(exit)\" 0
        | \"[interpreter]\" \"$path(exit)\" 0
        | \"[interpreter]\" \"$path(exit)\" 0
    "]
    set pids [pid $f]
    lassign $pids pid1 pid2 pid3
    set list [tcl::process list]
    set statuses [tcl::process status -wait]
    set status1 [lindex [tcl::process status $pid1] 1]
    set status2 [lindex [tcl::process status $pid2] 1]
    set status3 [lindex [tcl::process status $pid3] 1]
    expr {
           [llength $pids] eq 3
        && [llength $list] eq 3
        && [lsearch $list $pid1] >= 0
        && [lsearch $list $pid2] >= 0
        && [lsearch $list $pid3] >= 0
        && [dict size $statuses] eq 3
        && [dict get $statuses $pid1] eq $status1
        && [dict get $statuses $pid2] eq $status2
        && [dict get $statuses $pid3] eq $status3
        && $status1 eq 0
        && $status2 eq 0
        && $status3 eq 0
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== process-5.3 FAILED

==== thread-9.1 transfer of a channel from its own file event handler FAILED
==== Contents of test case:

    exec [interpreter] << {
        package require Thread
        set handler {
            proc handle {chan} {
                thread::transfer $::other $chan
                thread::send $::other [list fileevent $chan writable [list handle $chan]]
            }
        }
        eval $handler
        set other [thread::create]
        thread::send $other [list set other [thread::id]]
        thread::send $other $handler
        handle [open [expr {$tcl_platform(platform) eq "windows" ? "NUL" : "/dev/null"}] w]
        after 3000 {puts ok; exit}
        vwait forever
    }

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: ok
child killed: segmentation violation
    while executing
"exec [interpreter] << {
        package require Thread
        set handler {
            proc handle {chan} {
                thread::transfer $::other $chan
                thread::send $::other [li..."
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: CHILDKILLED 480903 SIGSEGV {segmentation violation}
==== thread-9.1 FAILED
Referenced by3
  • a3c26a4561Fix io-78.1 failing under valgrind [20ca033dee] check-in2026-11-04 15:27:35
  • f88b1e95c3Fix io-78.1 failing under valgrind [20ca033dee] check-in2026-11-04 15:23:16
  • 7e984069dbFix io-78.1 failing under valgrind [20ca033dee]: the child could exit before the parent wrote, so [puts] itself failed with EPIPE, and the leaked pipe channel and unreaped child then broke iortrans-3.1 and process-3.x..5.x in the same process. The child now waits for a signal file, and the cleanup closes the channel. check-in2026-11-02 22:20:02
serhiy.storchakawiki2026-11-02 22:29:04

Most of these are one cause. io-78.1 (from [7aa8fd34c4]) starts a child that exits at once; under valgrind it has already exited when the parent writes, so puts itself fails with EPIPE. The cleanup did not close the channel, and with -singleproc 1 the leaked pipe and its unreaped child break iortrans-3.1 (stray file10) and process-3.x..5.x (an extra entry in tcl::process list). Forcing the early exit reproduces the same 10 failures without valgrind.

Proposed fix in branch io-test-pipe-reader-alive: the child waits for a signal file, and the cleanup closes the channel.

thread-9.1 is a race in the Thread package, not in Tcl: ThreadExitProc overwrites a transfer result that already succeeded with "target thread died", so the worker splices the channel back while the exiting main thread already owns it ("SpliceChannel: trying to add channel used in different list"). About 1 in 150 runs under load. Skipping completed results in ThreadExitProc fixes it; the same applies to thread::send results.

jan.nijtmanswiki2026-11-04 15:26:18

Merged to [trunk]. Let's see what tonight's CI build does.

jan.nijtmanswiki2026-11-05 17:17:28

Now merged to [core-9-0-branch] too.

Closing.

Log in (anonymous is fine) to add a comment.