Skip to content

fix(escape): instrument pointer dereferences via StarExpr#28

Merged
kolkov merged 1 commit into
mainfrom
fix/issue-27-starexpr
Dec 19, 2025
Merged

fix(escape): instrument pointer dereferences via StarExpr#28
kolkov merged 1 commit into
mainfrom
fix/issue-27-starexpr

Conversation

@kolkov

@kolkov kolkov commented Dec 19, 2025

Copy link
Copy Markdown
Owner

Summary

Critical bug fix for Issue #27 reported by @thepudds (Go Team member).

Problem: Pointer dereferences like *ptr++ were not being instrumented, causing false negatives.

Root cause: Go parser uses *ast.StarExpr for pointer dereference in IncDecStmt, but our code only checked *ast.UnaryExpr.

Before fix: 0 writes, 0 reads instrumented for *ptr++
After fix: Race correctly detected

Changes

Test plan

  • Unit tests added for StarExpr handling
  • @thepudds reproduction case now detects race
  • All existing tests pass
  • golangci-lint: 0 issues
  • Coverage: 85.7%

Fixes: #27

Root cause: Go parser uses *ast.StarExpr for pointer dereference in
IncDecStmt (e.g., *ptr++ parses as IncDecStmt with X = StarExpr),
but our code only checked *ast.UnaryExpr.

Changes:
- Add StarExpr handling in Visit() switch statement
- Add visitStarExpr() function for pointer dereference instrumentation
- Add StarExpr handling in extractReads()
- Add StarExpr handling in extractAddress()
- Add TestInstrumentFile_StarExprPointerDeref test
- Add TestInstrumentFile_StarExprInGoroutine test (thepudds reproduction)
- Update CHANGELOG.md for v0.8.2

Before fix: 0 writes, 0 reads instrumented for *ptr++
After fix: Race correctly detected in @thepudds example

Fixes: #27
@codecov

codecov Bot commented Dec 19, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.45%. Comparing base (ea08d2e) to head (a7ee29c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   69.30%   69.45%   +0.14%     
==========================================
  Files          28       28              
  Lines        2913     2933      +20     
==========================================
+ Hits         2019     2037      +18     
  Misses        777      777              
- Partials      117      119       +2     
Flag Coverage Δ
unittests 69.45% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/racedetector/instrument/visitor.go 73.23% <100.00%> (+0.77%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea08d2e...a7ee29c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kolkov kolkov merged commit 97cb8a6 into main Dec 19, 2025
14 checks passed
@kolkov kolkov deleted the fix/issue-27-starexpr branch December 19, 2025 16:43
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.

bug(escape): Pointer dereferences incorrectly skipped when pointer doesn't escape

1 participant