diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-02 10:27:19 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-02 10:27:19 +0300 |
| commit | df373db740383b16050d75544604e596138eb8c8 (patch) | |
| tree | 621a9beb0b37bbd3f86d2f699a6e12ad35bec0e4 /integrationtests/timer_test.go | |
| parent | 0cfdd29db2f9cae372617ef01ed4aecc2f6fa93d (diff) | |
fix(close): deregister fd only on successful close (ret==0)
applyFdCloseState evicted the fd->path mapping (fdState + proc-fd cache)
on every close exit, ignoring the return value. A failed close — most
importantly EBADF ("fd isn't a valid open file descriptor"), but also
EINTR/EIO — did not release any descriptor we track, so dropping the
mapping there would let a later genuine close or a reuse of the fd
number resolve against stale/empty state.
Gate the eviction on ret==0, mirroring the ret==0 guard already used by
applyCloseRangeState for close_range. close's exit tracepoint is
generated as a ret_event (UNCLASSIFIED), so the exit carries the close
return value in RetEvent.Ret.
Tests: the close-exit event was being built as an fd_event, which does
not match the real BPF wire format (sys_exit_close emits EXIT_RET_EVENT).
Add a makeExitCloseEvent helper that emits the correct ret_event, route
all 18 close-exit call sites and TestHandleFdExitCloseClearsProcFdCache
through it, and add CloseFailureTest asserting a failed close (ret=-1)
leaves the fd tracked.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'integrationtests/timer_test.go')
0 files changed, 0 insertions, 0 deletions
