Skip to content

test: fix null async tcp client dereference in tcp_async_client_integration_test#46109

Open
davidvo-lyft wants to merge 1 commit into
envoyproxy:mainfrom
davidvo-lyft:davidvo/43233-tcp-async-client-flake
Open

test: fix null async tcp client dereference in tcp_async_client_integration_test#46109
davidvo-lyft wants to merge 1 commit into
envoyproxy:mainfrom
davidvo-lyft:davidvo/43233-tcp-async-client-flake

Conversation

@davidvo-lyft

Copy link
Copy Markdown
Contributor

Commit Message: test: fix null async tcp client dereference in tcp_async_client_integration_test

Additional Description:
test_network_async_tcp_filter destroys its AsyncTcpClient in the first onData() when
kill_after_on_data is set. With half close enabled, the downstream payload and FIN can be
delivered to the filter in two separate read dispatches, so a second onData() (and the downstream
onEvent() close handling) ran against the already destroyed client and dereferenced it, causing
the intermittent segfault reported in the issue. The coalescing of payload and FIN into one read
event is nondeterministic, which is why the flake was hard to reproduce. This guards the filter
onData() and downstream onEvent() paths against a null client and adds a deterministic
regression test, ClientTearDownSplitFin, that delivers the FIN as a separate write so the second
read dispatch always occurs.

Risk Level: Low (test only, no production code change).

Testing: ClientTearDownSplitFin fails 20 out of 20 runs on main (segfault, faulting address
0x0 in the downstream read dispatch, matching the crash in the issue) and passes after the guards.
The full //test/integration:tcp_async_client_integration_test target passes 200 out of 200 runs
(--runs_per_test=200) locally in the CI docker image (clang), zero failures. check_format passes.

Docs Changes: N/A

Release Notes: N/A (test only)

Platform Specific Features: N/A

Fixes #43233

Generative AI disclosure: This change was developed with AI assistance (Claude Code). I have
reviewed and understand every line, the read dispatch and half close race that produces the crash,
and the deterministic reproducer, and I take full ownership of the submission and of addressing
review feedback.

…ration_test

With half close enabled, the downstream payload and FIN can arrive at the
test network filter in two separate read dispatches. The first dispatch
destroys the async client via the kill_after_on_data path, and the second
dispatch dereferenced the destroyed client and segfaulted, which is the
CI flake reported in issue envoyproxy#43233. Guard the filter onData and downstream
onEvent paths against a null client, and add a ClientTearDownSplitFin
regression test that delivers the FIN as a separate read event to
reproduce the crash deterministically.

Signed-off-by: David Vo <davidvo@lyft.com>
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.

tcp_async_client_integration_test is flaky

1 participant