Skip to content

Document, test, and fix --race-check instrumentation#8846

Open
tautschnig wants to merge 4 commits intodiffblue:developfrom
tautschnig:race-check-fixes
Open

Document, test, and fix --race-check instrumentation#8846
tautschnig wants to merge 4 commits intodiffblue:developfrom
tautschnig:race-check-fixes

Conversation

@tautschnig
Copy link
Collaborator

Please review commit-by-commit. Overall summary:

Improve --race-check: docs, bug fixes, dirty-locals support

Document the Eraser-inspired write-guard instrumentation scheme. Fix the incorrect "floating-point" help text and add --race-check to the cprover manual.

Fix missed races: instrument GOTO guards, function call arguments, and return statements (not just ASSIGN). Exclude function symbols from race checking. Set property_class to "race-check" on generated assertions.

Use dirtyt analysis to treat address-taken locals as shared, matching goto-symex behavior.

Add 11 regression tests in regression/goto-instrument/race-check/.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copilot AI review requested due to automatic review settings March 3, 2026 19:30
@tautschnig tautschnig self-assigned this Mar 3, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the --race-check instrumentation in goto-instrument by documenting the approach, fixing user-facing help/manpage text, extending instrumentation to more instruction kinds (guards, call arguments, returns), and adding regression tests.

Changes:

  • Extend race-check read/write discovery and instrumentation to cover SET_RETURN_VALUE and additional instruction kinds beyond ASSIGN.
  • Improve documentation (inline header overview + user manual entry) and fix incorrect --race-check help/manpage text.
  • Add a new regression test suite under regression/goto-instrument/race-check/ to exercise newly-covered cases.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/goto-instrument/rw_set.cpp Treat SET_RETURN_VALUE expressions as reads for race analysis.
src/goto-instrument/race_check.h Add high-level documentation of the race-check instrumentation scheme and API docs.
src/goto-instrument/race_check.cpp Add dirty-local support, exclude function symbols, tag generated assertions with property_class="race-check", and instrument additional instruction kinds.
src/goto-instrument/goto_instrument_parse_options.cpp Fix --race-check help text.
regression/goto-instrument/race-check/*.c / *.desc Add new regression tests for read/write race patterns and newly instrumented constructs.
doc/man/goto-instrument.1 Fix --race-check manpage entry text.
doc/cprover-manual/properties.md Document --race-check in the user manual properties table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tautschnig
Copy link
Collaborator Author

Looks like GitHub is having issues: https://www.githubstatus.com/incidents/n07yy1bk6kc4.

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 91.17647% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.08%. Comparing base (7ff43f7) to head (bae0cd8).

Files with missing lines Patch % Lines
src/goto-instrument/race_check.cpp 90.62% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8846      +/-   ##
===========================================
+ Coverage    80.00%   80.08%   +0.07%     
===========================================
  Files         1700     1700              
  Lines       188271   188294      +23     
  Branches        73       73              
===========================================
+ Hits        150632   150787     +155     
+ Misses       37639    37507     -132     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

tautschnig and others added 4 commits March 4, 2026 13:32
Add Doxygen documentation to race_check.h explaining the Eraser-inspired
write-guard instrumentation scheme for data-race detection, including the
two kinds of races detected (R/W and W/W), the 5-step instrumentation
sequence, and how pointer dereferences are resolved through value-set
analysis for alias-aware race detection.

Document internal functions in race_check.cpp.

Fix the --race-check help text, man page, and cprover manual: the option
performs general data-race checking, not floating-point specific checks.
Add --race-check to the goto-instrument properties table in the cprover
manual.

Add regression tests exercising the basic race-check scenarios:
write-write, read-write, no-race (thread-local), no-race (sequential),
conditional write, and pointer-based race detection.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Set property_class to "race-check" on all generated assertions, consistent
with other instrumentation passes (e.g., uninitialized-check, stack-depth).
This enables users to filter race-check properties by class and produces
property names like [main.race-check.1] instead of [main.1].

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
…red variables

The race-check instrumentation previously only instrumented ASSIGN
instructions. This missed R/W data races where shared variables are
read by other instruction types:

- GOTO: reading a shared variable in a branch condition (if/while guard)
- FUNCTION_CALL: reading shared variables as function arguments, writing
  return values
- SET_RETURN_VALUE: reading a shared variable in a return statement
- ASSUME/ASSERT: reading shared variables in conditions

For these instructions, R/W and W/W race-check assertions are now
inserted before the instruction to detect concurrent writes by other
threads.

Also add SET_RETURN_VALUE handling to rw_set_loct::compute(), which
previously did not track reads from return statements.

Also exclude function symbols from race checking: function symbols
are not variables and should not generate race-check assertions when
read as part of a FUNCTION_CALL instruction.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
…taken locals

The race-check instrumentation previously only considered globally shared
variables (symbol.is_shared()). Local variables whose address is taken
and passed to other threads ("dirty locals") were not instrumented,
missing potential data races.

Now use the dirtyt analysis, consistent with how goto-symex determines
shared access: a variable is considered shared if symbol.is_shared() or
dirty(identifier). The dirty analysis is computed once over all functions
in the goto_modelt overload.

Add a CORE regression test (dirty-local.desc) that verifies the
instrumentation is generated for a dirty local by matching on the
--show-goto-functions output.

Add a KNOWNBUG regression test (dirty-local-verification.desc) that
attempts full verification of the dirty-local race. This is marked
KNOWNBUG because CBMC's symex currently aborts with "pointer handling
for concurrency is unsound" when a pointer to a local is shared between
threads.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
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.

4 participants