-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[vm] Fix data race in Function::unoptimized_code (#61800) #61823
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
Conversation
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at:
https://dart-review.googlesource.com/c/sdk/+/457660
Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly.
Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR).
Summary
Fixes a ThreadSanitizer-detected data race when accessing
Function::unoptimized_codebetween the main compilation thread and background optimizer thread.Issue
Fixes #61800
ThreadSanitizer detected a data race where:
unoptimized_codeviaFunction::set_unoptimized_code()during compilationunoptimized_codeduring the inlining optimization pass inCallSiteInliner::GetParsedFunction()This unsynchronized access could lead to:
Changes
Applied proper acquire-release synchronization to
Function::unoptimized_codeaccessors:runtime/vm/object.h:
unoptimized_code()getter to usestd::memory_order_acquirewhen readingruntime/vm/object.cc:
set_unoptimized_code()setter to usestd::memory_order_releasewhen writingThe existing
COMPRESSED_POINTER_FIELDmacro already supports templated memory ordering, so this change leverages that existing infrastructure.Memory Ordering Semantics
Related Work
This follows the same pattern used for other concurrent code access in the Dart VM and is consistent with the existing memory ordering support in the
COMPRESSED_POINTER_FIELDmacro infrastructure.TEST=language/vm/regression_39193_test
Contribution guidelines:
dart format.Note that this repository uses Gerrit for code reviews. Your pull request will be automatically converted into a Gerrit CL and a link to the CL written into this PR. The review will happen on Gerrit but you can also push additional commits to this PR to update the code review.