Skip to content

Fix: Handle EBADF in synserver accept instead of aborting#12930

Open
bryancall wants to merge 2 commits intoapache:masterfrom
bryancall:fix-synserver-accept-ebadf
Open

Fix: Handle EBADF in synserver accept instead of aborting#12930
bryancall wants to merge 2 commits intoapache:masterfrom
bryancall:fix-synserver-accept-ebadf

Conversation

@bryancall
Copy link
Contributor

@bryancall bryancall commented Feb 27, 2026

Problem

The regression suite intermittently crashes in synserver_vc_accept with:

Fatal: synserver_vc_accept: unexpected event 3, accept errno: Bad file descriptor (9)

This happens because multiple EXCLUSIVE_REGRESSION_TEST tests (SDK_API_HttpTxnTransform, SDK_API_HttpAltInfo, etc.) share port 3300 and their teardown can overlap with a pending accept. When synserver_stop/synserver_delete closes the listening socket, net_accept() gets EBADF from accept() and sends EVENT_ERROR with -EBADF as data to the continuation.

Related PRs

Changes

  • Handle EVENT_ERROR + EBADF gracefully -- in both synserver_vc_accept and synserver_vc_refuse, check specifically for EVENT_ERROR with data == -EBADF and return instead of aborting. This is the expected error when the listening socket was closed during teardown.
  • Preserve abort for other errors -- any unexpected event or errno still triggers ink_abort with full diagnostics, so new failure modes won't be silently swallowed.

Testing

When the listening socket is closed by synserver_stop while the accept
is still pending, net_accept sends EVENT_ERROR with -EBADF.  Instead
of calling ink_abort (which crashes the regression suite), log a
warning and return gracefully.  Other unexpected events still abort.

This race occurs because multiple EXCLUSIVE_REGRESSION_TEST tests
share port 3300 and their teardown can overlap with a pending accept.
@bryancall bryancall added this to the 10.2.0 milestone Feb 27, 2026
@bryancall bryancall self-assigned this Feb 27, 2026
@zwoop zwoop requested a review from Copilot February 28, 2026 00:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the synserver accept continuations used by the API regression tests to treat EBADF during teardown as an expected race (listener closed while an accept is pending), preventing intermittent test-suite aborts.

Changes:

  • Handle TS_EVENT_ERROR with data == -EBADF in synserver_vc_accept() and synserver_vc_refuse() by returning instead of aborting.
  • Preserve existing abort behavior (with diagnostics) for all other unexpected events / errno payloads.

Switch EBADF handling from Warning() to Dbg(dbg_ctl_SockServer, ...)
since this is an expected teardown race and Warning is too noisy.
Restore the comment explaining the -4095 Linux MAX_ERRNO guard.
@bryancall
Copy link
Contributor Author

[approve ci autest 0]

@bryancall
Copy link
Contributor Author

[approve ci clang-analyzer]
[approve ci fedora]
[approve ci freebsd]
[approve ci rocky]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants