fix(escape): instrument pointer dereferences via StarExpr#28
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.StarExprfor pointer dereference inIncDecStmt, but our code only checked*ast.UnaryExpr.Before fix:
0 writes, 0 reads instrumentedfor*ptr++After fix: Race correctly detected
Changes
*ast.StarExprhandling inVisit()switch statementvisitStarExpr()function for pointer dereference instrumentationStarExprhandling inextractReads()andextractAddress()Test plan
Fixes: #27