🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.bugs
4 messages
4 total messages Started by bugzilla-noreply Sun, 25 Oct 2026 23:59
[Bug 300076] [patch] linuxulator / inotify: epoll_ctl(EPOLLIN | EPOLLOUT) on inotify fd fails with EINVAL, causing EAGAIN busy l...
#251
Author: bugzilla-noreply
Date: Sun, 25 Oct 2026 23:59
91 lines
5818 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300076

            Bug ID: 300076
           Summary: [patch] linuxulator / inotify: epoll_ctl(EPOLLIN |
                    EPOLLOUT) on inotify fd fails with EINVAL, causing
                    EAGAIN busy loop in Go (fsnotify) binaries
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: harimawo@harimawo.com

Created attachment 276483
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=276483&action=edit
Patch for linux_event.c and vfs_inotify.c

[Problem Description]
When running Linux binaries written in Go that use `fsnotify` (inotify) under
FreeBSD 15 Linuxulator, the process enters a tight busy loop consuming 100%+
CPU and rapidly filling logs with:
`fsnotify error: read : resource temporarily unavailable` (EAGAIN).

[Root Cause]
1. `fsnotify` calls `inotify_init1(IN_CLOEXEC | IN_NONBLOCK)` and wraps the
returned descriptor with Go's `os.NewFile(uintptr(fd), "")`.
2. Because `O_NONBLOCK` is set on the descriptor, Go's runtime network poller
(`runtime/netpoll_epoll.go:netpollopen`) attempts to register the fd with
`epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev)` using:
   `ev.events = _EPOLLIN | _EPOLLOUT | _EPOLLRDHUP | _EPOLLET`
   On Linux, registering both `EPOLLIN` and `EPOLLOUT` on a read-only inotify
descriptor succeeds (write readiness simply never fires).
3. In FreeBSD's Linuxulator (`sys/compat/linux/linux_event.c:epoll_to_kevent`),
`EPOLLIN | EPOLLOUT` is translated into two kevents: `EVFILT_READ` and
`EVFILT_WRITE`.
4. However, `inotify_kqfilter()` in `sys/kern/vfs_inotify.c` only accepts
`EVFILT_READ` and returns `EINVAL` for `EVFILT_WRITE`:
   if (kn->kn_filter != EVFILT_READ)
       return (EINVAL);
   (Note: By contrast, `pipe_kqfilter()` in `sys/kern/sys_pipe.c` handles
unsupported filter directions by attaching a no-op filter `pipe_nfiltops` and
returning 0.)
5. Because `EVFILT_WRITE` fails with `EINVAL`, `linux_epoll_ctl()` fails with
`EINVAL`.
6. Go's `internal/poll.FD.Init()` treats the `epoll_ctl` failure as "not
pollable" (`pollable = false`), while the file descriptor itself remains
non-blocking (`FNONBLOCK`).
7. Subsequent `Read()` calls by `fsnotify` immediately return `EAGAIN` from
`inotify_read()` without parking on `epoll_wait()`, resulting in an infinite
unthrottled `EAGAIN` retry loop.

[How to Reproduce]
Run any Linux Go binary (such as Google Antigravity CLI `agy`) that watches
files/directories with `github.com/fsnotify/fsnotify` under Linuxulator on
FreeBSD 15.1.

[Proposed Fix]
The attached patch addresses the issue in two places:
1. `sys/compat/linux/linux_event.c`: In `epoll_to_kevent()`, mask out
`LINUX_EPOLL_EVRD` if `(fp->f_flag & FREAD) == 0` and mask out
`LINUX_EPOLL_EVWR` if `(fp->f_flag & FWRITE) == 0`. This also prevents the same
issue for other read-only special descriptors such as `timerfd`.
2. `sys/kern/vfs_inotify.c`: In `inotify_kqfilter()`, accept `EVFILT_WRITE`
using a no-op filter (`inotify_nfiltops`) that never fires, matching the
behavior of `pipe_kqfilter()` in `sys/kern/sys_pipe.c`.

[Note / Disclosure]
The root cause analysis and patch creation were conducted using Google
Antigravity CLI with Gemini 4 Argon (High), and the patch has been built and
verified on real FreeBSD 15.1-RELEASE (amd64) hardware.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300076] [patch] linuxulator / inotify: epoll_ctl(EPOLLIN | EPOLLOUT) on inotify fd fails with EINVAL, causing EAGAIN busy l...
#252
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 00:12
17 lines
2731 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300076

Mark Linimon <linimon@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #276483|0                           |1
           is patch|                            |

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300076] linuxulator / inotify: epoll_ctl(EPOLLIN | EPOLLOUT) on inotify fd fails with EINVAL, causing EAGAIN busy loop in G...
#257
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 00:16
25 lines
3217 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300076

Mark Linimon <linimon@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[patch] linuxulator /       |linuxulator / inotify:
                   |inotify: epoll_ctl(EPOLLIN  |epoll_ctl(EPOLLIN |
                   || EPOLLOUT) on inotify fd   |EPOLLOUT) on inotify fd
                   |fails with EINVAL, causing  |fails with EINVAL, causing
                   |EAGAIN busy loop in Go      |EAGAIN busy loop in Go
                   |(fsnotify) binaries         |(fsnotify) binaries

--- Comment #1 from Mark Linimon <linimon@FreeBSD.org> ---
^Triage: now that Bugzilla Attachments have the Patch flag,
the [patch] convention is obsolete.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300076] linuxulator / inotify: epoll_ctl(EPOLLIN | EPOLLOUT) on inotify fd fails with EINVAL, causing EAGAIN busy loop in G...
#258
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 00:19
16 lines
2692 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300076

Mark Linimon <linimon@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|bugs@FreeBSD.org            |emulation@FreeBSD.org

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads