-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add proper locking in TranslateSigHelper #120143
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
There was a problem hiding this 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 fixes a thread safety issue in the TranslateSigHelper function by adding proper locking when updating metadata. The function was directly accessing and modifying metadata without acquiring the necessary write lock, which could lead to data corruption in multi-threaded scenarios.
Key Changes
- Add proper write lock acquisition before metadata operations
- Restructure function to use error handling pattern with goto-based cleanup
- Ensure thread-safe access to metadata structures
I don't have this error when building locally. I guess MSVC has different rules? Anyway, I pushed a tentative fix. Unfortunately I don't have a Linux environment ready to test. |
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18049188130 |
|
/cc @jkoritzinsky |
TranslateSigHelperupdates the metadata without going through theRegMetainterface (by directly extracting them_pStgdbfield). When doing so, it omits to acquire the write lock, which can end up corrupting the metadata when multiple threads are running concurrently.Fixes #119958