[libcxx-commits] [libcxx] [libc++] Fix out-of-bounds read in the associative container query benchmarks (PR #227070)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 29 07:54:25 PDT 2026


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/227070

>From c2f2e12a401febc7d13a26734d414eec7401a3e0 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 28 Sep 2026 13:17:59 -0400
Subject: [PATCH] [libc++] Fix out-of-bounds read in the associative container
 query benchmarks

The query benchmarks for associative containers would access the pool
of keys to use in the benchmark out-of-bounds.
---
 .../containers/associative/associative_container_benchmarks.h   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
index 0291c650d891c..76f1b7c3c65df 100644
--- a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
@@ -725,7 +725,7 @@ void associative_container_benchmarks(std::string container) {
       for (auto _ : st) {
         Key const& key = keys[draws[i]];
         auto result    = func(c, key);
-        i              = (i == N_DRAWS ? 0 : i + 1);
+        i              = (i + 1 == N_DRAWS ? 0 : i + 1);
         benchmark::DoNotOptimize(c);
         benchmark::DoNotOptimize(result);
         benchmark::ClobberMemory();



More information about the libcxx-commits mailing list