Skip to content
Tcl Source Code View Ticket
Login

View Ticket

zlib-9.3 hangs on netbsd

Closed / Fixed81cb2b674f2a83a0f0936f41ae8d678ce24edcb8Created 8 years agoUpdated 45 days ago
Descriptionplain2019-05-04 20:32:39
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
Referenced by4
  • 70363207b0Fix [81cb2b674f]: zlib-8.3 and zlib-9.3 connected to localhost check-in2026-10-19 13:11:21
  • 05360d8891Fix [81cb2b674f]: zlib-8.3 and zlib-9.3 connected to localhost check-in2026-10-18 22:02:26
  • c3bf6dd052Fix [81cb2b674f]: zlib-8.3 and zlib-9.3 connected to localhost check-in2026-10-16 14:47:13
  • 2e3abb1180Fix [81cb2b674f]: zlib-8.3 and zlib-9.3 connected to localhost, which can be ::1 while the first listener is on 127.0.0.1. On NetBSD, which assigns ports in sequence per address family, the client could then get the port of the server and connect to itself. Connect to the first listening address, as the other tests do. check-in2026-10-12 20:04:34
emiliano (claiming to be Emiliano)plain2019-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?
emilianoplain2019-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.storchakawiki2026-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.nijtmanswiki2026-10-18 22:03:23

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

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

Thanks!

jan.nijtmanswiki2026-10-19 13:12:14

Now merged to 8.6 as well.

Closing

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