Repository navigation
Fix the nightly Valgrind failure: a race in the connect-handler test - #1044
Merged
Merged
Conversation
The test opened a probe server to learn a free port, then closed it and built the backend, expecting it to retry until the real server listened. A backend that has never reached its server does not retry; it gives up after the first refused dial. The test passed only while the backend's first dial lost the race against the listen, and under Valgrind's scheduling it won, which is the nightly memcheck failure at test_push_net.cpp:324. The server now listens before the backend exists. The backend runs on a loop the test holds until both handlers are installed. Tasks on a loop run in the order posted, so the connect handler is in place before the first dial starts, whatever the thread timing. A 500 ms pause where the old setup raced fails it at the same assertion; the same pause in the new setup passes. 50 native runs and one under Valgrind pass. Closes #1043 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmVLNhUvbWZjv85Hx2saxn
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.
Fixes the nightly Valgrind memcheck failure (#1043) at
test_push_net.cpp:324. #1005 was the same failure. Valgrind reported no memory errors either time; this was a race in the test.Cause: the test closed its probe server before building the backend, expecting the backend to keep retrying until the real server listened. A
SocketBackendthat has never reached its server does not retry. It gives up after the first refused dial (socket_backend.hpp, "fail fast, no retry"). So the test passed only when the backend's first dial lost the race against the listen. Under Valgrind's scheduling the dial won, and the 10 s wait could never succeed.Fix: the server listens before the backend exists. The backend runs on an
IoLoopthe test holds until both handlers are installed. Tasks run in the order posted, so the connect handler is in place before the first dial starts, whatever the thread timing. The test still checks connect, connect + reconnect, in that order.Verified:
valgrind --error-exitcode=99passes.morph_net_testspasses in full, 258 cases.Test-only change; no library code is touched.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BmVLNhUvbWZjv85Hx2saxn