Repository navigation
listener: fix use-after-free in filter_chain_benchmark_test at exit - #48757
Merged
jwendell merged 2 commits intoOct 27, 2026
Merged
Conversation
The benchmark library creates the FilterChainBenchmarkFixture instances during static initialization and destroys them at exit. Each fixture held a Logger::Context, which saves a raw pointer to the context that was current when it was built and reactivates it on destruction. With libstdc++ the registered benchmarks are destroyed in registration order, so the second fixture reactivates the context of the first one after it was freed. Under the GCC build this corrupts the heap and tcmalloc aborts at exit with "CHECK in BitmapPushBatch". libc++ destroys them in reverse order, which is why clang builds, including the sanitizer ones, do not see it. The fixture context is redundant: test/benchmark/main.cc installs a logging context for the whole run. Remove it. Signed-off-by: William Dauchy <[email protected]>
Signed-off-by: William Dauchy <[email protected]>
jwendell
approved these changes
Oct 27, 2026
jwendell
enabled auto-merge (squash)
October 27, 2026 11:38
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]>
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.
Commit Message: listener: fix use-after-free in filter_chain_benchmark_test at exit
Each
FilterChainBenchmarkFixtureheld aLogger::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 withCHECK in BitmapPushBatch(libc++ destroys them in reverse order, so clang builds are unaffected).The fixture context is redundant since
test/benchmark/main.ccalready installs one for the whole run. Remove it.Additional Description:
The GCC job of
Envoy/Checksfails after all benchmarks have run on PRs that invalidate this test's cache entry, e.g. #48470 (job) and #48449 (job). 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.Logger::Contextlifetimes traced with gdb on the GCC build:Risk Level: Low. Test only.
Testing:
bazel test --config=gcc --nocache_test_results //test/common/listener_manager:filter_chain_benchmark_test_benchmark_testin theenvoy-buildimage (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.