Skip to content

fix: data race on a tracepoint's shared argument-type info (1.7.2)#38

Merged
Jo5ta merged 1 commit into
mainfrom
fix/argument-types-init-race
Jul 11, 2026
Merged

fix: data race on a tracepoint's shared argument-type info (1.7.2)#38
Jo5ta merged 1 commit into
mainfrom
fix/argument-types-init-race

Conversation

@Jo5ta

@Jo5ta Jo5ta commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to the sanitizer work (1.7.2).

The TSan leg intermittently flagged a data race in get_argument_sizes:

data race arguments.c:74 in get_argument_sizes — Location '…::_clltk_types'

first_time_check lazily initializes each tracepoint's shared static _clltk_types on first use (type fixups in types[], flex_size). When many threads hit the same tracepoint at once, several run that one-time init concurrently and race on it. This is original code — the sanitizer leg surfaced a latent race that had been present since the initial commit; it slipped past branch CI because TSan detects races only probabilistically.

Fix: serialize the init under the global lock (a spinlock in the kernel) and publish with an acquire/release flag, so once warmed up the check is a plain lock-free load. The init was already idempotent, so no behavior change.

Also widens the live-stress drain window so its tail assertion is deterministic under CI load (occasionally read == written - 1 on a slow runner).

Verified: normal ctest 680/680, full TSan suite 676/676 (including the race-triggering read_parallel_overwhelmed), kernel module builds with the new sync usage in arguments.c.

TSan (added in the sanitizer leg) intermittently caught a data race in
get_argument_sizes: the one-time lazy init (first_time_check) mutates
the tracepoint's shared static _clltk_types (type fixups, flex_size),
and concurrent first callers of the same tracepoint raced on it. This
is original code, not new - the sanitizer leg simply surfaced it, and
it slipped past the branch CI because TSan detects races only
probabilistically.

Serialize the init under the global lock (a spinlock in the kernel) and
publish with an acquire/release flag, so once warmed up the check stays
a plain lock-free load. The init was already idempotent, so there is no
behavior change.

Also widen the live-stress drain window so its tail check is
deterministic under CI load (was read == written - 1 on a slow runner).

Signed-off-by: Jo5ta <jo5ta@mail.de>
@Jo5ta Jo5ta merged commit 35c8fd9 into main Jul 11, 2026
10 checks passed
@Jo5ta Jo5ta deleted the fix/argument-types-init-race branch July 11, 2026 12:50
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.

1 participant