Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-20
16:45 • Closed ticket [f1a25e8a50]: New thread panics "Tcl_InitNotifier: could not ... artifact: 9b110b6bc0 user: jan.nijtmans
2026-11-18
11:53
Fix [f1a25e8a50]: New thread panics when stdin is closed check-in: aac882246a user: jan.nijtmans tags: core-9-0-branch
2026-11-17
11:27 • Pending ticket [f1a25e8a50]: New thread panics "Tcl_InitNotifier: could not... artifact: 5f03592f0b user: jan.nijtmans
11:21
Fix [f1a25e8a50]: New thread panics when stdin is closed check-in: 64ce9de2a3 user: jan.nijtmans tags: trunk, main
2026-11-14
17:51 • Ticket [f1a25e8a50] New thread panics "Tcl_InitNotifier: could not create t... artifact: df3a0b5a61 user: serhiy.storchaka
17:50
Fix [f1a25e8a50]: New thread panics "Tcl_InitNotifier: could not create trigger eventfd" when stdin ... closed check-in: f20443fb11 user: serhiy.storchaka tags: notifier-fd-zero
16:49 • New ticket [f1a25e8a50] New thread panics "Tcl_InitNotifier: could not crea... artifact: 3334849368 user: serhiy.storchaka

New thread panics "Tcl_InitNotifier: could not create trigger eventfd" when stdin is closed

Closed / Fixedf1a25e8a5090333da9c02de51f04f2914fea7bfaCreated 18 days agoUpdated 12 days ago
Descriptionmarkdown2026-11-14 16:49:44
close stdin
set t [testthread create {testthread wait}]

run in tcltest panics with

Tcl_InitNotifier: could not create trigger eventfd
Every new thread fails the same way. For example, thread::create or tpool::post from the Thread package after close stdin.

With stdin closed, fd 0 is free, so eventfd() in the new thread's PlatformEventsInit() gets fd 0. unix/tclEpollNotfy.c treats that as an error (if (tsdPtr->triggerEventFd <= 0)) instead of checking for < 0.

TclpFinalizeNotifier() makes the same assumption: it only closes the eventfd, trigger pipe and epoll/kqueue fds if they are non-zero, so a notifier fd that is 0 is never closed. unix/tclKqueueNotfy.c has the same check in finalize.

Affects 9.0 and 9.1 on Linux, where epoll is the default notifier. 8.6 is not affected.

Referenced by3
  • aac882246aFix [f1a25e8a50]: New thread panics when stdin is closed check-in2026-11-18 11:53:12
  • 64ce9de2a3Fix [f1a25e8a50]: New thread panics when stdin is closed check-in2026-11-17 11:21:20
  • f20443fb11Fix [f1a25e8a50]: New thread panics "Tcl_InitNotifier: could not create trigger eventfd" when stdin is closed. With stdin closed, eventfd() returns fd 0, which the epoll notifier treated as an error. TclpFinalizeNotifier() in the epoll and kqueue notifiers also did not close a trigger or epoll/kqueue fd that is 0, so the kqueue notifier leaked it. check-in2026-11-14 17:50:35
serhiy.storchakawiki2026-11-14 17:51:58

Proposed fix in branch notifier-fd-zero: the epoll notifier now accepts an eventfd of 0. The epoll and kqueue notifiers now also close their trigger and epoll/kqueue descriptors when one is 0; until now the kqueue notifier leaked fd 0. Test thread-9.2. Tested on Linux (epoll) and FreeBSD (kqueue).

jan.nijtmanswiki2026-11-17 11:27:12

Fixed in [trunk]

OK for backport to 9.0 (not done yet)

jan.nijtmanswiki2026-11-20 16:45:14

Now also merged to core-9-0-branch

Many thanks!

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