Skip to content

http3: keep the persistent QUIC info alive while its pools use it - #47893

Merged
mattklein123 merged 5 commits into
envoyproxy:mainfrom
bpalermo:http3-persistent-quic-info-lifetime
Oct 20, 2026
Merged

mattklein123 merged 5 commits into
envoyproxy:mainfrom
bpalermo:http3-persistent-quic-info-lifetime

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Commit Message: http3: keep the persistent QUIC info alive while its pools use it
Additional Description:

Removing an HTTP/3 upstream cluster while it has requests in flight can crash Envoy with a use-after-free in the QUIC client connection (SIGSEGV/SIGBUS in quic::QuicConnection::OnCanWrite → CanWrite, reached from EnvoyQuicClientConnection::onFileEvent, or from an alarm).

Quic::PersistentQuicInfoImpl holds the QUIC helpers shared by a cluster's HTTP/3 connections: the connection helper with its EnvoyQuicClock, the alarm factory, the QUIC config, the crypto stream factory and the writer factory. Since #19862 it is owned by the thread-local ClusterEntry (quic_info_, a unique_ptr), Http3ConnPoolImpl and ConnectivityGrid hold it by reference, and every upstream QUIC connection keeps raw pointers into it (QuicConnection::clock_, each alarm's clock). When CDS removes the cluster, the worker erases the thread-local cluster and ~ClusterEntry calls drainConnPools() with DrainAndDelete, which lets busy clients finish their streams, and then destroys its members, including the info. The pools live on in host_http_conn_pool_map_ until their streams end, with connections pointing into freed memory; the next write-ready event or alarm reads the freed clock. It needs streams in flight at the removal, so it is intermittent. Http3ConnPoolImpl's destructor already makes sure connections are torn down before the pool drops the info; the cluster entry's ordering was the gap.

Fix: PersistentQuicInfoPtr becomes a shared_ptr, and Http3ConnPoolImpl, Http3::allocateConnPool and ConnectivityGrid take and hold it instead of a reference. The cluster keeps creating and holding the info and passes its pointer to the pools, so the info lives until the last pool using it is gone (a pool destroys its connections first). createQuicNetworkConnection still takes a reference; it is only called by a pool that holds the info. No behavior change on a healthy path.

Testing: Http3ConnPoolImplTest.PoolKeepsPersistentQuicInfoAliveAfterItsCreatorReleasesIt creates the info as the cluster manager does, builds a pool on it and releases the creator's reference: the info must stay alive while the pool exists and be freed with it (fails without the fix: freed at release). The HTTP/3 pool, connection grid, cluster manager and QUIC client connection factory tests and the QUIC HTTP and multiplexed integration tests pass. Found through a crash on a deployment that removed HTTP/3 clusters under load; the fault was symbolized to the clock read in QuicConnection::CanWrite.

Verified on main (after #47806): the new test and the HTTP/3 pool and grid tests pass, and CI is green.

Risk Level: low
Testing: unit test (new), existing HTTP/3 pool, grid, cluster manager and QUIC integration tests
Docs Changes: N/A
Release Notes: bug_fixes
Platform Specific Features: N/A

The persistent QUIC info (connection helper and its clock, alarm factory,
QUIC config, crypto stream factory, writer factory) was owned by the
thread-local cluster entry, while every HTTP/3 pool held it by reference
and every upstream QUIC connection kept raw pointers into it. Removing a
cluster destroys its entry after only draining its pools, so a pool with
active streams, and its connections, outlived the info; the next write
event or alarm on such a connection read the freed clock and crashed.

The info is now shared: the cluster keeps creating and holding it, and
each HTTP/3 pool and connectivity grid holds a reference to it, so it
lives until the last pool using it is gone. Connections are destroyed
with their pool, before that reference is released.

Signed-off-by: Bruno Palermo <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #47893 was opened by bpalermo.

see: more, trace.

Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

@bpalermo
bpalermo marked this pull request as ready for review September 30, 2026 12:00
bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 30, 2026
…ied patches, config tables, CLAUDE.md package map (#1081)

* docs: refresh after the QUIC/hot-restart work — rollback advice, carried patches, config tables, CLAUDE.md package map

- runbook: the 1.0.11 escape hatch rolls the proxy (a1bcf05 vs 71be75f) and
  drops the #1074 patch unless proxy.image + proxy.supervisor.image are
  pinned; #979 is merged (soak-verdict placeholder); #1069 named as the
  #1054 root cause; new #1074 SIGBUS entry (#1077, envoyproxy/envoy#47893,
  chart 1.0.13); stray "0 disables the prune" moved.
- configuration: proxy drainStrategy/skipParentStats/terminationGrace,
  agent eastWestQuicIdleTimeout + flag, controller identity-gate flags,
  identity-ready section, cni-install --otlp-pin-endpoint, edge/registrar
  rows (the shared edge Service has no `type`; overload is fixed_heap).
- CLAUDE.md/AGENTS.md: TPROXY capture, QUIC/xDS/supervisor/CNI packages,
  port map, carried patches; proxy-ready ships in the supervisor image.
- README, getting-started, e2e, proposals 037/038/040 status lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs: record the 2026-09-30 re-soak verdict for the unconditional-QUIC build (#979)

Every QUIC gate passed and #1073/#1074 did not recur; the run failed only on
liveness (9 / 719,984) from a hot-restart/agent-restart overlap (#1085).
First-use 503 NC burst and TRIPLE 504 UT filed as #1086 and #1087.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/wait

Comment thread envoy/http/persistent_quic_info.h Outdated
Comment on lines +21 to +24
// Returns shared ownership of this object when it is owned by a PersistentQuicInfoPtr, or
// nullptr when it is owned some other way (e.g. by a test), in which case the owner is
// responsible for outliving its users.
std::shared_ptr<PersistentQuicInfo> keepAlive() { return weak_from_this().lock(); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems pretty convoluted. Can't we just always use a shared_ptr for this thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: the pools and the grid now take and hold a PersistentQuicInfoPtr (a shared_ptr), and enable_shared_from_this/keepAlive() are gone. The cluster manager passes its pointer through.

The pools and the connectivity grid take and hold a PersistentQuicInfoPtr
instead of a reference plus a keep-alive recovered through
enable_shared_from_this.

Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo

bpalermo commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@mattklein123

Copy link
Copy Markdown
Member

Please merge main

/wait

…-info-lifetime

Signed-off-by: Bruno Palermo <[email protected]>

# Conflicts:
#	source/common/http/http3/conn_pool.cc
#	test/common/http/http3/conn_pool_test.cc
@bpalermo

Copy link
Copy Markdown
Contributor Author

@mattklein123 Merged main. The only conflict was with #48241 (effectiveSni) in the HTTP/3 pool constructor and its test fixture; kept both. HTTP/3 pool, grid, cluster manager and QUIC integration tests pass locally. PTAL

@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

@mattklein123
mattklein123 merged commit 77b5125 into envoyproxy:main Oct 20, 2026
27 checks passed
@bpalermo
bpalermo deleted the http3-persistent-quic-info-lifetime branch October 20, 2026 13:17
bpalermo added a commit to bpalermo/aether that referenced this pull request Nov 1, 2026
…er1054c and aether1074 (proposal 045)

- envoy/envoy_api 1.40.0.envoy -> 1.41.0-dev.20261028.011e396.envoy, registry
  a1264b53 -> 36d481b01b (the commit that added the snapshot).
- Dropped patches: aether1054c (envoyproxy/envoy#47868, 2eff6e8ccf) and
  aether1074 (envoyproxy/envoy#47893, 77b512527c), both in the snapshot.
- aether1050 refreshed from envoyproxy/envoy#47834's head against its merge
  base, which already contains #47068: the +/- lines are unchanged, only the
  test file's context moved. aether1054 refreshed by hand: two one-line
  insertions whose neighbouring runtime guards were removed upstream. 47740
  and aether1126 apply unchanged.
- .bazelversion 8.7.0 -> 9.3.1 (Envoy's own; the 1.40.0 closure does not load
  under Bazel 9, so the move cannot land first). .bazelrc follows upstream:
  merge_fixed_and_default_shell_env removed, system_include_paths and the
  rules_rust linker_messages flags added, the toolchains_llvm compiler-rt and
  libunwind overrides dropped (the envoy module links compiler-rt + libunwind
  since envoyproxy/envoy#48641).
- proxy-wasm-cpp-host .envoy -> .envoy.1, rules_cc 0.2.25 -> 0.2.27,
  rules_python 2.3.3 -> 2.4.5: what the new closure selects.
- The MODULE.bazel comment that still called #47893 open is rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx
bpalermo added a commit to bpalermo/aether that referenced this pull request Nov 1, 2026
…er1054c and aether1074 (proposal 045) (#1733)

* proxy: Envoy 1.41.0-dev.20261028.011e396 under Bazel 9.3.1; drop aether1054c and aether1074 (proposal 045)

- envoy/envoy_api 1.40.0.envoy -> 1.41.0-dev.20261028.011e396.envoy, registry
  a1264b53 -> 36d481b01b (the commit that added the snapshot).
- Dropped patches: aether1054c (envoyproxy/envoy#47868, 2eff6e8ccf) and
  aether1074 (envoyproxy/envoy#47893, 77b512527c), both in the snapshot.
- aether1050 refreshed from envoyproxy/envoy#47834's head against its merge
  base, which already contains #47068: the +/- lines are unchanged, only the
  test file's context moved. aether1054 refreshed by hand: two one-line
  insertions whose neighbouring runtime guards were removed upstream. 47740
  and aether1126 apply unchanged.
- .bazelversion 8.7.0 -> 9.3.1 (Envoy's own; the 1.40.0 closure does not load
  under Bazel 9, so the move cannot land first). .bazelrc follows upstream:
  merge_fixed_and_default_shell_env removed, system_include_paths and the
  rules_rust linker_messages flags added, the toolchains_llvm compiler-rt and
  libunwind overrides dropped (the envoy module links compiler-rt + libunwind
  since envoyproxy/envoy#48641).
- proxy-wasm-cpp-host .envoy -> .envoy.1, rules_cc 0.2.25 -> 0.2.27,
  rules_python 2.3.3 -> 2.4.5: what the new closure selects.
- The MODULE.bazel comment that still called #47893 open is rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* proxy: carry aether1733, envoy --mode validate no longer segfaults on a QUIC listener

#1733's proxy workflow (run 41308410926, both arches) failed
//agent/test/envoy_validate:envoy_validate_test: `envoy --mode validate` of
node_bootstrap.json, edge_bootstrap.json and the ADS reconnect test's
bootstrap died with SIGSEGV in
Quic::ActiveQuicListenerFactory::initializeWorkerRouting().

envoyproxy/envoy#45504, in the 011e396 snapshot, moved the QUIC listener's
socket options there (behind envoy.restart_features.defer_worker_routing_init,
default true) and applies them to every worker's listen socket. Validation
mode creates no sockets (ValidationListenerComponentFactory::createListenSocket
returns nullptr), so *socket dereferences null. Upstream main still has it.
The proxy-supervisor's check before every hot restart on a changed bootstrap
is `envoy --mode validate`, so this would have blocked every bootstrap change
in production.

The patch skips a null socket, which only validation mode produces, as
validation did before #45504. Regression test: envoy_validate_test in the
proxy workflow, red on 8ce601a. Not reported upstream (on hold).

The "FilterStateMatcherValidationError.Key: value length must be at least 1
characters" line in the same log is TestAgentCaptureListenerAndTableValidate's
expected rejection ("refused as it must be"); that test passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* proxy: aether1733's production exposure is a future static QUIC listener; refresh the extension count

- The aether1733 comment (MODULE.bazel, README) overstated the exposure: the
  chart's bootstraps carry static clusters only (listeners come over LDS), so
  the supervisor's pre-restart `--mode validate` does not crash today. A future
  bootstrap with a static QUIC listener would fail it, and every hot restart.
  The crash needs concurrency > 1 (the BPF reuseport option); raw-UDP
  listeners are unaffected.
- extensions_build_config.bzl: 354 upstream extensions - 35 dropped = 319 at
  011e396. The five new ones are named; tls.certificate_selectors.dynamic_modules
  is dropped by the existing pattern, and the four that compile in
  (priority_load_shed, host_allowlist, uri_template matcher,
  ai_protocol_manager in-memory buffer) are unused by aether and reach none of
  the wasm, dynamic-module or Rust machinery, so the policy keeps them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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