Tcl Source Code

View Ticket
Login
Ticket UUID: 81cb2b674f2a83a0f0936f41ae8d678ce24edcb8
Title: zlib-9.3 hangs on netbsd
Type: Bug Created on: 2019-05-04 20:32:39
Submitter: emiliano Assigned to: jan.nijtmans
Subsystem: 25. Channel System Severity: Severe
Priority: 5 Medium Last modified: 2026-10-18 22:03:23
Status: Pending Closed by: nobody
Resolution: Fixed Closed on:
Version: 9.1.0
Description:
Starting from check-in f51188e3058a46f0 (core-8-branch) test zlib-9.3 hangs on
NetBSD 8.0, both i386 and amd64. Quick inspection shows that it happens when
the script executes the [update] command.
The test was copied and slightly modified to catch the hanging command in
a file named "sock.tcl". Here is an interactive session:

emiliano@cabernet:~/src/tcl/unix$ echo "source sock.tcl" | make shell 
Warning: tclStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
LD_LIBRARY_PATH=`pwd`:  TCLLIBPATH="/home/emiliano/src/tcl/unix/pkgs"  TCL_LIBRARY="/home/emiliano/src/tcl/library" ./tclsh 
berfore update
entering server callback
leaving server callback
^C
-- hit ctrl-c after 10 seconds --
emiliano@cabernet:~/src/tcl/unix$ cat sock.tcl 
    package require tcltest
    set srv [socket -myaddr localhost -server {apply {{c a p} {
        puts "entering server callback"
        chan configure $c -translation binary -buffering none -blocking 0
        puts -nonewline $c [string repeat a 81920]
        close $c
        puts "leaving server callback"
    }}} 0]
    set file [tcltest::makeFile {} test.gz]
    lassign [chan configure $srv -sockname] addr name port
    set sin [socket localhost $port]
    chan configure $sin -translation binary
    puts "berfore update"
    update
    puts "after update"
    set fout [open $file wb]
    after 1000 {set ::total timeout}
    puts here
    fcopy $sin $fout -command {apply {{c {e {}}} {
        set ::total [expr {$e eq {} ? $c : $e}]
    }}}
    vwait ::total
    after cancel {set ::total timeout}
    close $sin; close $fout
    puts [list read $::total size [file size $file]]
    close $srv
    tcltest::removeFile $file
emiliano@cabernet:~/src/tcl/unix$

Besides the hang, I failed to see why this test is in zlib,test since there's nothing related to compression on this code. I think it should be moved to socket.test
User Comments:
emiliano (claiming to be Emiliano) added on 2019-05-04 21:23:13:
More testing shows that the bug is not dependant on the kqueue notifier.
Building with the select() based notifier also hangs.

BTW, I've not found an easy way to disable the "advanced notifier support"
feature from the configure script; had to delete the NOTIFIER_KQUEUE define
from the generated Makefile. Did I miss something?

emiliano added on 2019-05-09 16:11:35:
Further info: top shows that the hang is a busy wait:

  PID USERNAME PRI NICE   SIZE   RES STATE      TIME   WCPU    CPU COMMAND
  940 emiliano  29    0  8992K 5708K RUN        3:04 96.10% 96.09% tcltest

serhiy.storchaka added on 2026-10-12 20:05:24:

Still fails on NetBSD 10.1 with 9.1, but now with a timeout instead of a hang. The client socket connects to itself: its local address is the same as the remote one (::1 and the server port). The test connects to localhost, which is ::1, while the server port comes from the first listener, on 127.0.0.1. As in [5350f32153], NetBSD assigns ports in sequence (per address family), so the client can get the port the server is listening on, and once it happens it happens every time.

Proposed fix in branch zlib-test-self-connect: connect to the first listening address, as the other zlib tests do.


jan.nijtmans added on 2026-10-18 22:03:23:

Fix merged to [c3bf6dd052|trunk] and core-9-0-branch

core-8-6-branch still to be done.

Thanks!