Bug 294014 - kevent doesn't notify when UNIX socket is closed
Summary: kevent doesn't notify when UNIX socket is closed
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2026-03-24 07:16 UTC by Nicolas BREMOND
Modified: 2026-05-09 20:45 UTC (History)
5 users (show)

See Also:
markj: mfc-stable15?
markj: mfc-stable14-


Attachments
The source code to reproduce the bug (4.29 KB, text/plain)
2026-03-24 07:16 UTC, Nicolas BREMOND
no flags Details
The ktrace on FreeBSD 14.2 (expected behavior) (27.41 KB, text/plain)
2026-03-24 07:18 UTC, Nicolas BREMOND
no flags Details
The ktrace on FreeBSD 15.0 (missing notification for socket) (30.31 KB, text/plain)
2026-03-24 07:18 UTC, Nicolas BREMOND
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas BREMOND 2026-03-24 07:16:05 UTC
Created attachment 269066 [details]
The source code to reproduce the bug

We noticed a different behavior of kevent between the version 15.0 and 14.3 which looks like a bug in 15.0

You can find attached an example of code to reproduce the behavior.

The issue is a missing kevent notification when the remote side of an unix socket is closed. This occurs under the following context:
- a write has been made on the local side of the socket to fill the write buffer before the remote side is closed.
- another kevent call is made before closing the socket, unrelated to the socket operations. In my example, we create an EVFILT_TIMER and wait for it.


I tried to git bisect but it's taking too much time and I failed to completely automate it. However, so far so I saw the issue in base d17bfb237065587c72db05a5bafc6bcab1206cb9 while base 712806fc4b5470eb7d9ce537e3cdf3b386455d86 works fine.

Is it a real bug, or did I forgot something in my code to be notified on closed connection ?
Comment 1 Nicolas BREMOND 2026-03-24 07:18:00 UTC
Created attachment 269067 [details]
The ktrace on FreeBSD 14.2 (expected behavior)
Comment 2 Nicolas BREMOND 2026-03-24 07:18:53 UTC
Created attachment 269068 [details]
The ktrace on FreeBSD 15.0 (missing notification for socket)
Comment 3 Nicolas BREMOND 2026-03-25 10:08:17 UTC
I finally managed to have a bisect script, it seems that the change was introduced by base d15792780760ef94647af9b377b5f0a80e1826bc
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2026-05-02 00:04:15 UTC
I believe https://reviews.freebsd.org/D56764 will fix this.
Comment 5 Benjamin Jacobs 2026-05-03 19:37:01 UTC
(In reply to Mark Johnston from comment #4)

Your patch fixes the tests of devel/canpnproto, see #294259 .
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-05-03 23:10:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=476805133f5736c2c8638e41d2b5d8dd2c597f3a

commit 476805133f5736c2c8638e41d2b5d8dd2c597f3a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-05-03 15:46:22 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-05-03 21:51:49 +0000

    unix: Make sure we signal EOF on the write side when disconnecting

    Add a regression test.

    PR:             294014
    Reported by:    diizzy
    Reviewed by:    glebius
    MFC after:      1 week
    Fixes:          d15792780760 ("unix: new implementation of unix/stream & unix/seqpacket")
    Differential Revision:  https://reviews.freebsd.org/D56764

 sys/kern/uipc_usrreq.c       |  2 ++
 tests/sys/kern/unix_stream.c | 77 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 17 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-05-09 19:25:04 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f06697907f360b02682594c6179a7361644d3c87

commit f06697907f360b02682594c6179a7361644d3c87
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-05-03 15:46:22 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-05-09 19:16:02 +0000

    unix: Make sure we signal EOF on the write side when disconnecting

    Add a regression test.

    PR:             294014
    Reported by:    diizzy
    Reviewed by:    glebius
    MFC after:      1 week
    Fixes:          d15792780760 ("unix: new implementation of unix/stream & unix/seqpacket")
    Differential Revision:  https://reviews.freebsd.org/D56764

    (cherry picked from commit 476805133f5736c2c8638e41d2b5d8dd2c597f3a)

 sys/kern/uipc_usrreq.c       |  2 ++
 tests/sys/kern/unix_stream.c | 77 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 17 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2026-05-09 20:45:16 UTC
A commit in branch releng/15.1 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=037b285b80e5cb35c8e9cec4e85966b20f03d91a

commit 037b285b80e5cb35c8e9cec4e85966b20f03d91a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-05-03 15:46:22 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-05-09 20:44:04 +0000

    unix: Make sure we signal EOF on the write side when disconnecting

    Add a regression test.

    Approved by:    re (cperciva)
    PR:             294014
    Reported by:    diizzy
    Reviewed by:    glebius
    MFC after:      1 week
    Fixes:          d15792780760 ("unix: new implementation of unix/stream & unix/seqpacket")
    Differential Revision:  https://reviews.freebsd.org/D56764

    (cherry picked from commit 476805133f5736c2c8638e41d2b5d8dd2c597f3a)
    (cherry picked from commit f06697907f360b02682594c6179a7361644d3c87)

 sys/kern/uipc_usrreq.c       |  2 ++
 tests/sys/kern/unix_stream.c | 77 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 17 deletions(-)