Skip to content

Commit ec73266

Browse files
etrclaude
andcommitted
valgrind: broaden shared_ptr control-block suppression to whole _Sp_counted_base
A fresh drd run (4fb73d5) surfaced a new benign ConflictingAccess in webserver_register_path_prefix: the MHD worker dropping the last shared_ptr ref to a resource during modded_request::~modded_request in request_completed, while the main thread unregistered under route_cache's std::mutex. The access is the libstdc++ control-block teardown (~_Sp_counted_base / _M_weak_release), atomic refcount (_Lock_policy _S_atomic) which drd/helgrind cannot model. This is the same benign class the existing _M_release entry covered, but the teardown surfaces through different control-block methods each run depending on thread timing, so a per-method match plays whack-a-mole. Broaden the match to the whole _Sp_counted_base family (dtor, _M_release, _M_weak_release, _M_dispose) in both supp files. Pure libstdc++ frame — a real libhttpserver locking race surfaces a libhttpserver top frame, never _Sp_counted_base; TSan, which models the atomic refcount, is green on these tests. Mirrors the existing broad-third-party entries (basic_string, vector, _Rb_tree, _Sp_counted_ptr_inplace). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NpysYDDJac63yz2mZKKiDf
1 parent 4fb73d5 commit ec73266

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

test/valgrind-drd.supp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,22 @@
7373
fun:thread_main_handle_connection
7474
}
7575

76-
# --- libstdc++ shared_ptr control-block refcount ----------------------------
77-
# _M_release decrements an atomic use-count; DRD does not model the libstdc++
78-
# atomic and reports a benign counter conflict.
79-
{
80-
libstdcxx-shared-ptr-refcount-release
81-
drd:ConflictingAccess
82-
fun:*_Sp_counted_base*_M_release*
76+
# --- libstdc++ shared_ptr control-block (atomic refcount + teardown) ---------
77+
# The shared_ptr control block (_Sp_counted_base and derived) keeps an atomic
78+
# use-/weak-count DRD does not model, so it reports a benign conflict whenever
79+
# the last ref is dropped on one thread while another touched the block. The
80+
# teardown surfaces through many control-block methods depending on timing
81+
# (_M_release, _M_weak_release, _M_dispose, ~_Sp_counted_base), so match the
82+
# whole _Sp_counted_base family rather than a single method -- otherwise each
83+
# timing-dependent valgrind run hits a different frame (observed: the MHD worker
84+
# dropping the last resource ref in modded_request::~modded_request during
85+
# request_completed while the main thread unregisters). Pure libstdc++ frame; a
86+
# real libhttpserver locking race surfaces a libhttpserver top frame. TSan is
87+
# green on the same tests.
88+
{
89+
libstdcxx-shared-ptr-control-block
90+
drd:ConflictingAccess
91+
fun:*_Sp_counted_base*
8392
}
8493

8594
# --- libstdc++ atomic<shared_ptr> free-function ops (_Sp_locker spinlock) -----

test/valgrind-helgrind.supp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,23 @@
7070
fun:thread_main_handle_connection
7171
}
7272

73-
# --- libstdc++ shared_ptr control-block refcount ----------------------------
74-
# _M_release decrements an atomic use-count (_Lock_policy _S_atomic); Helgrind
75-
# does not model the libstdc++ atomic and reports a benign counter race.
73+
# --- libstdc++ shared_ptr control-block (atomic refcount + teardown) ---------
74+
# The shared_ptr control block (_Sp_counted_base and its _Sp_counted_ptr_inplace
75+
# derived) maintains an atomic use-/weak-count (_Lock_policy _S_atomic) that
76+
# Helgrind does not model, so it reports a benign race whenever the last ref is
77+
# dropped on one thread while another touched the block. The teardown surfaces
78+
# through many control-block methods depending on timing -- _M_release,
79+
# _M_weak_release, _M_dispose, ~_Sp_counted_base -- so match the whole
80+
# _Sp_counted_base family rather than a single method (each valgrind run
81+
# otherwise hits a different frame; observed the worker dropping the last
82+
# resource ref in modded_request::~modded_request during request_completed while
83+
# the main thread unregisters). Pure libstdc++ frame: a real libhttpserver
84+
# locking race surfaces a libhttpserver top frame, never _Sp_counted_base. TSan,
85+
# which models the atomic refcount, is green on the same tests.
7686
{
77-
libstdcxx-shared-ptr-refcount-release
87+
libstdcxx-shared-ptr-control-block
7888
Helgrind:Race
79-
fun:*_Sp_counted_base*_M_release*
89+
fun:*_Sp_counted_base*
8090
}
8191

8292
# --- libstdc++ atomic<shared_ptr> free-function ops (_Sp_locker spinlock) -----

0 commit comments

Comments
 (0)