fix(evm): fix data race in interpreter mode under multi-thread test frame#369
fix(evm): fix data race in interpreter mode under multi-thread test frame#369cmgCr wants to merge 2 commits intoDTVMStack:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a concurrency bug in the EVM interpreter by making the EVMResource “current execution context” globals thread-local, preventing cross-thread data races when multiple interpreters run concurrently.
Changes:
- Converted
EVMResource::CurrentFrameandEVMResource::CurrentContexttostatic thread_localmembers. - Updated the corresponding static member definitions in
opcode_handlers.cppto match the TLS storage class.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/evm/opcode_handlers.h | Declares the current frame/context pointers as thread_local to isolate per-thread interpreter state. |
| src/evm/opcode_handlers.cpp | Defines the TLS-backed static members to complete the thread-local conversion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static thread_local EVMFrame *CurrentFrame; | ||
| static thread_local InterpreterExecContext *CurrentContext; |
There was a problem hiding this comment.
This change is specifically intended to prevent cross-thread races by moving execution context into TLS, but there doesn’t appear to be any regression test covering concurrent interpreter execution. Please add a unit/integration test that runs two interpreters in parallel threads with different frames/contexts and asserts opcode execution reads the correct per-thread context (i.e., no cross-contamination).
There was a problem hiding this comment.
The bug occured in inner multithread test frame.
4a35da4 to
b472730
Compare
⚡ Performance Regression Check Results✅ Performance Check Passed (interpreter)Performance Benchmark Results (threshold: 20%)
Summary: 194 benchmarks, 0 regressions ✅ Performance Check Passed (multipass)Performance Benchmark Results (threshold: 20%)
Summary: 194 benchmarks, 0 regressions |
…data race
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:
6. Release note