Repository navigation
base: Fix etserver crash on transient accept() errors - #756
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #756 +/- ##
==========================================
+ Coverage 87.27% 87.37% +0.10%
==========================================
Files 71 72 +1
Lines 5368 5395 +27
Branches 501 502 +1
==========================================
+ Hits 4685 4714 +29
+ Misses 682 681 -1
+ Partials 1 0 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
UnixSocketHandler::accept() called FATAL_FAIL on any accept() errno other than EAGAIN/EWOULDBLOCK, aborting the entire server. accept(2) routinely returns benign per-connection errors -- notably ECONNABORTED (the peer reset the connection before we accepted it) and EINTR. These are surfaced readily on FreeBSD by clients that connect and immediately disconnect (keepalive/reconnect churn), crashing etserver. Treat EAGAIN, EWOULDBLOCK, ECONNABORTED, and EINTR as non-fatal and return -1; the accept loop already handles this by retrying. Genuinely unexpected errnos still fail fatally. Backtrace on FreeBSD: #0 thr_kill () at thr_kill.S:4 MisterTea#1 __raise (s=s@entry=6) at /usr/src/lib/libc/gen/raise.c:50 MisterTea#2 abort () at /usr/src/lib/libc/stdlib/abort.c:64 MisterTea#3 el::base::utils::abort (status=1, reason="Fatal log at [.../src/base/UnixSocketHandler.cpp:146] ...") at external_imported/easyloggingpp/src/easylogging++.cc:125 MisterTea#4 el::base::Writer::triggerDispatch () at external_imported/easyloggingpp/src/easylogging++.cc:2653 MisterTea#5 el::base::Writer::processDispatch () at external_imported/easyloggingpp/src/easylogging++.cc:2616 MisterTea#6 el::base::Writer::~Writer () at external_imported/easyloggingpp/src/easylogging++.h:3209 MisterTea#7 et::UnixSocketHandler::accept (this=..., sockFd=10) at src/base/UnixSocketHandler.cpp:146 MisterTea#8 et::ServerConnection::acceptNewConnection (this=..., fd=10) at src/base/ServerConnection.cpp:17 MisterTea#9 et::TerminalServer::run (this=...) at src/terminal/TerminalServer.cpp:79 MisterTea#10 main (argc=6, argv=...) at src/terminal/TerminalServerMain.cpp:203
Add unit tests for UnixSocketHandler::isTransientAcceptError(), the helper that decides which accept() errnos are recoverable. This exercises the ECONNABORTED and EINTR cases (the FreeBSD crash) directly, plus EAGAIN/ EWOULDBLOCK, and confirms genuine errors (EBADF, EINVAL, ...) stay fatal. Also add an end-to-end check that accept() on a non-blocking listening socket with no pending connection returns -1 instead of aborting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UnixSocketHandler::accept() called FATAL_FAIL on any accept() errno other than EAGAIN/EWOULDBLOCK, aborting the entire server. accept(2) routinely returns benign per-connection errors -- notably ECONNABORTED (the peer reset the connection before we accepted it) and EINTR. These are surfaced readily on FreeBSD by clients that connect and immediately disconnect (keepalive/reconnect churn), crashing etserver.
Treat EAGAIN, EWOULDBLOCK, ECONNABORTED, and EINTR as non-fatal and return -1; the accept loop already handles this by retrying. Genuinely unexpected errnos still fail fatally.
Backtrace on FreeBSD:
#0 thr_kill () at thr_kill.S:4
#1 __raise (s=s@entry=6) at /usr/src/lib/libc/gen/raise.c:50
#2 abort () at /usr/src/lib/libc/stdlib/abort.c:64
#3 el::base::utils::abort (status=1, reason="Fatal log at [.../src/base/UnixSocketHandler.cpp:146] ...")
at external_imported/easyloggingpp/src/easylogging++.cc:125
#4 el::base::Writer::triggerDispatch () at external_imported/easyloggingpp/src/easylogging++.cc:2653
#5 el::base::Writer::processDispatch () at external_imported/easyloggingpp/src/easylogging++.cc:2616
#6 el::base::Writer::~Writer () at external_imported/easyloggingpp/src/easylogging++.h:3209
#7 et::UnixSocketHandler::accept (this=..., sockFd=10) at src/base/UnixSocketHandler.cpp:146
#8 et::ServerConnection::acceptNewConnection (this=..., fd=10) at src/base/ServerConnection.cpp:17
#9 et::TerminalServer::run (this=...) at src/terminal/TerminalServer.cpp:79
#10 main (argc=6, argv=...) at src/terminal/TerminalServerMain.cpp:203