Tcl Source Code

View Ticket
Login
Ticket UUID: 6f8bbbb34bf84bf0032c9f647e7e480e4ad03904
Title: kqueue notifier hangs on OpenBSD
Type: Bug Created on: 2026-07-04 16:50:39
Submitter: stu Assigned to: nobody
Subsystem: 01. Notifier Severity: Critical
Priority: 5 Medium Last modified: 2026-07-07 15:57:10
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2026-07-07 15:57:10
Version: 9.1b0
Description:
If the kqueue notifier is configured on OpenBSD, tests will hang.
First test to hang is basic-26.1, if skipped then chan-16.9.

checking for advanced notifier support... kqueue(2) : tests hang
checking for advanced notifier support... none : tests pass, all the way through to the end

UPD: 9.1a1 looks good.
User Comments:
sebres added on 2026-07-04 17:48:49:

I could bet that it'd be the change of unix/tclKqueueNotfy.c from [def988e9cd676b5b]:


-    if (timePtr != NULL) {
+	timeout.tv_sec = timePtr->sec;
+	timeout.tv_usec = timePtr->usec;
-    if (time > 0) {
+	timeout.tv_sec = time / 1000000;
+	timeout.tv_usec = time % 1000000;
because if time is negative for some reasons, it'd wait infinitely instead of leave waiting proc immediately.

But oldlaptop tested it and it seems to hang further.

However, I'm still sure it shall be rewritten anyway for backwards compatibility reasons (e. g. some extension may call Tcl_WaitForEvent with some negative value and behavior gets changed completely).


sebres added on 2026-07-04 18:18:33:

Fixed in [6f8bbbb34bf84bf0]. Thx stu and oldlaptop!


stu added on 2026-07-04 18:20:17:
Tests pass with this patch, inspired by unix/tclEpollNotfy.c.

Index: unix/tclKqueueNotfy.c
--- unix/tclKqueueNotfy.c.orig
+++ unix/tclKqueueNotfy.c
@@ -640,7 +640,7 @@ TclpWaitForEvent(
      * for, we return with a negative result rather than blocking forever.
      */
 
-    if (time > 0) {
+    if (time >= 0) {
        timeout.tv_sec = time / 1000000;
        timeout.tv_usec = time % 1000000;
        timeoutPtr = &timeout;

jan.nijtmans added on 2026-07-07 15:57:10:

Many thanks for this fix!