Skip to content

Fix the nightly Valgrind failure: a race in the connect-handler test - #1044

Merged
Yaraslaut merged 1 commit into
masterfrom
fix/push-net-connect-race
Oct 24, 2026
Merged

Yaraslaut merged 1 commit into
masterfrom
fix/push-net-connect-race

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

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 SocketBackend that 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 IoLoop the 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:

  • Control: a 500 ms pause where the old setup raced fails it at the same assertion as the nightly run. The same pause in the new setup passes.
  • Native: 50 of 50 runs of the test pass.
  • Valgrind: one run under valgrind --error-exitcode=99 passes.
  • Suite: morph_net_tests passes in full, 258 cases.

Test-only change; no library code is touched.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BmVLNhUvbWZjv85Hx2saxn

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
@Yaraslaut
Yaraslaut merged commit 842701f into master Oct 24, 2026
8 of 9 checks passed
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.

1 participant