Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: segfault on Takesnapshot when go build -race #252

Merged
merged 3 commits into from
Dec 11, 2024
Merged

Conversation

y1yang0
Copy link
Member

@y1yang0 y1yang0 commented Dec 10, 2024

The crash occurs because newproc1 is executed by the m0.g0 scheduling goroutine, which lacks racectx. However, contextPropagate inserted by -race forcibly adds a call to racefuncenter(), which expects racectx to be valid. Since m0.g0.racectx is 0, this leads to a crash.

One solution is to use the Go compiler's directive:

//go:norace
The //go:norace directive must be followed by a function declaration. It specifies that the function's memory accesses should be ignored by the race detector. This is most commonly used in low-level code invoked at times when it is unsafe to call into the race detector runtime.

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.81%. Comparing base (d71d610) to head (466a465).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #252   +/-   ##
=======================================
  Coverage   83.81%   83.81%           
=======================================
  Files          19       19           
  Lines         791      791           
=======================================
  Hits          663      663           
  Misses        102      102           
  Partials       26       26           

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

@y1yang0
Copy link
Member Author

y1yang0 commented Dec 11, 2024

Looks good, thanks.

@y1yang0 y1yang0 merged commit fec9612 into main Dec 11, 2024
9 checks passed
@y1yang0 y1yang0 deleted the yyang/fix_race branch December 11, 2024 07:31
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