Skip to content

opentelemetry: Add traceparent parse/serialize methods to SpanContextExtractor - #48449

Merged
botengyao merged 1 commit into
envoyproxy:mainfrom
dmcardle:otel-traceparent-parse-serialize
Nov 19, 2026
Merged

botengyao merged 1 commit into
envoyproxy:mainfrom
dmcardle:otel-traceparent-parse-serialize

Conversation

@dmcardle

@dmcardle dmcardle commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Commit Message: opentelemetry: Add traceparent parse/serialize methods to SpanContextExtractor

This new override will be used by McpFilter in PR #48038.

Additional Description: This PR was created with help from generative AI (Gemini). I fully understand the code.

For reference, here is the full PR chain:

  1. api: Add mode field to TraceContextPropagationConfig in mcp.proto #48249
  2. envoy/tracing: Add method Envoy::Tracing::Span::updateParent() #48250
  3. opentelemetry: Add traceparent parse/serialize methods to SpanContextExtractor #48449
  4. opentelemetry: Override Span::updateParent() #48448
  5. opentelemetry: Move traceparent size constants into common lib #48516
  6. mcp: Reparent active span based on body's traceparent #48038
  7. opentelemetry: Add bool field resample_on_update_parent to OpenTelemetryConfig #48450
  8. opentelemetry: Resample in Span::updateParent() #48451

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@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: #48449 was opened by dmcardle.

see: more, trace.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #48449 was ready_for_review by dmcardle.

see: more, trace.

@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch 2 times, most recently from 8585b17 to 88d1a94 Compare October 21, 2026 17:53
@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch 4 times, most recently from f91608f to cbf4efd Compare October 26, 2026 15:59
jwendell pushed a commit that referenced this pull request Oct 27, 2026
…48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. #48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and #48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch 2 times, most recently from 36fde18 to 5a38072 Compare October 28, 2026 14:07
botengyao pushed a commit that referenced this pull request Oct 29, 2026
…48249)

<!--
!!!ATTENTION!!!

If you are fixing **any** crash or **any** potential security issue,
**do not
open a pull request**.

Instead, please
[open a GitHub Security
Advisory](https://github.com/envoyproxy/envoy/security/advisories/new)
(preferred). Alternatively, you may email
[email protected].

Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description:

This is the first PR in a chain, with the high-level goal of getting
McpFilter to reparent the active span based on the request body's trace
context.

For reference, here is the full PR chain:

1. #48249
1. #48250
1. #48449
1. #48448
1. #48516
1. #48038
1. #48450
1. #48451

This PR was created with help from generative AI (Gemini). I fully
understand the code.

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: dmcardle <[email protected]>
@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch 2 times, most recently from 9ca7a92 to bec3013 Compare October 30, 2026 21:35
@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch from bec3013 to 98320b6 Compare November 2, 2026 15:34
@dmcardle

dmcardle commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/retest

botengyao pushed a commit that referenced this pull request Nov 3, 2026
<!--
!!!ATTENTION!!!

If you are fixing **any** crash or **any** potential security issue,
**do not
open a pull request**.

Instead, please
[open a GitHub Security
Advisory](https://github.com/envoyproxy/envoy/security/advisories/new)
(preferred). Alternatively, you may email
[email protected].

Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description: This change supports
#48038

This PR was created with help from generative AI (Gemini). I fully
understand the code.

For reference, here is the full PR chain:

1. #48249
1. #48250
1. #48449
1. #48448
1. #48516
1. #48038
1. #48450
1. #48451

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: dmcardle <[email protected]>
@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch from 98320b6 to 1392f26 Compare November 3, 2026 16:14
@dmcardle

dmcardle commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@yanavlasov This PR is up next, PTAL!

jwendell pushed a commit that referenced this pull request Nov 12, 2026
…48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. #48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and #48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit that referenced this pull request Nov 17, 2026
…48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. #48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and #48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 18, 2026
…nvoyproxy#48757)

Commit Message: listener: fix use-after-free in
filter_chain_benchmark_test at exit

Each `FilterChainBenchmarkFixture` held a `Logger::Context`, which
reactivates the previous context on destruction. The benchmark library
builds the fixtures at static initialization and destroys them at exit;
with libstdc++ this happens in registration order, so the second fixture
reactivates the first one's freed context. Under GCC this corrupts the
heap and tcmalloc aborts with `CHECK in BitmapPushBatch` (libc++
destroys them in reverse order, so clang builds are unaffected).

The fixture context is redundant since `test/benchmark/main.cc` already
installs one for the whole run. Remove it.

Additional Description:
The GCC job of `Envoy/Checks` fails after all benchmarks have run on PRs
that invalidate this test's cache entry, e.g. envoyproxy#48470
([job](https://github.com/envoyproxy/envoy/actions/runs/40478692516/job/122125067805))
and envoyproxy#48449
([job](https://github.com/envoyproxy/envoy/actions/runs/40354667795/job/121684997303)).
main looks green because its GCC runs take this result from the remote
cache. The bug is old; whether it aborts depends on heap layout.

```
33302 external/tcmalloc+/tcmalloc/span.h:465] CHECK in BitmapPushBatch: small_span_state_.bitmap.GetBit(idx) == 0 (true == 0)
... Aborted (core dumped) ... --skip_expensive_benchmarks -- --benchmark_min_time=0s
```

`Logger::Context` lifetimes traced with gdb on the GCC build:

```
CTOR     ...7740  FilterChainBenchmarkFixture_FilterChainManagerBuildTest_Benchmark   (static init)
CTOR     ...7bc0  FilterChainBenchmarkFixture_FilterChainFindTest_Benchmark           (static init)
CTOR     ...fb80  main
DTOR     ...fb80  main                         -> ACTIVATE ...7bc0
DTOR     ...7740  ~..._FilterChainManagerBuildTest_Benchmark (unique_ptr, freed)
DTOR     ...7bc0  ~..._FilterChainFindTest_Benchmark          -> ACTIVATE ...7740 (freed)
```

Risk Level: Low. Test only.
Testing: `bazel test --config=gcc --nocache_test_results
//test/common/listener_manager:filter_chain_benchmark_test_benchmark_test`
in the `envoy-build` image (gcc 13.3.0): fails on main (5af8d91),
passes 5/5 with this change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

AI assistance: prepared with AI assistance (Cursor agent). We reviewed
and understand all of it.

---------

Signed-off-by: William Dauchy <[email protected]>
(cherry picked from commit aedd2c4)
Signed-off-by: Ryan Northey <[email protected]>
botengyao
botengyao previously approved these changes Nov 18, 2026

@botengyao botengyao 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.

lgtm

@botengyao
botengyao enabled auto-merge (squash) November 18, 2026 18:53
@dmcardle

Copy link
Copy Markdown
Contributor Author

CI might have gotten stuck

@dmcardle

Copy link
Copy Markdown
Contributor Author

/retest

@botengyao

Copy link
Copy Markdown
Member

could you merge main?

auto-merge was automatically disabled November 19, 2026 17:08

Head branch was pushed to by a user without write access

@dmcardle
dmcardle force-pushed the otel-traceparent-parse-serialize branch from 1392f26 to 76e5cda Compare November 19, 2026 17:08
@botengyao
botengyao merged commit ca61574 into envoyproxy:main Nov 19, 2026
30 of 34 checks passed
yanavlasov pushed a commit that referenced this pull request Dec 1, 2026
This new override will be used by McpFilter in PR #48038.

Additional Description: This PR was created with help from generative AI
(Gemini). I fully understand the code.

For reference, here is the full PR chain:

1. #48249
1. #48250
1. #48449
1. #48448
1. #48516
1. #48038
1. #48450
1. #48451

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

---------

Signed-off-by: dmcardle <[email protected]>
yanavlasov pushed a commit that referenced this pull request Dec 2, 2026
This commit deduplicates constants related to W3C traceparent into
source/common/tracing/tracing_validation.h.

Additional Description:

This PR was created with help from generative AI (Gemini). I fully
understand the code.

For reference, here is the full PR chain:

1. #48249
1. #48250
1. #48449
1. #48448
1. #48516
1. #48038
1. #48450
1. #48451

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: dmcardle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants