You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Restore detached thread state after nested VM entry - #10175
Addresses the nested-entry restoration issue identified during the bootstrap investigation in #8944.
Summary
Preserve the previous attachment state across nested VM entry and saved-context restoration, including unwinding and interpreter initialization.
Keep callbacks inside allow_threads from leaving the thread attached during the remaining blocking work. This preserves GC stop-the-world cooperation and keeps suspended critical-section locks released until the outer scope resumes.
Written with Codex (GPT-6), reviewed by a human before submission.
Summary by CodeRabbit
Bug Fixes
Improved thread attachment handling when entering nested interpreters. Threads now preserve their prior attached or detached state after normal returns and panic unwinding, and remain detached until the enclosing thread-permission scope ends. This prevents nested interpreter activity from unexpectedly changing the parent thread’s attachment state.
No actionable comments were generated in the recent review.
Walkthrough
Interpreter sections and saved thread state now preserve the thread’s attachment status. Section teardown restores the enclosing interpreter only when it was attached on entry. A threading-only regression test covers nested entry from a detached parent during normal return and panic unwinding.
InterpreterSection records whether the enclosing interpreter was attached. Section setup and teardown use this state, and the bootstrap and current-VM paths pass it through. A threading-only test checks nested entry and restoration after return or panic unwinding.
Saved thread attachment state crates/vm/src/vm/thread.rs
SavedThreadState records whether the thread was attached. Saving detaches only an attached thread, and restoring reattaches only when the saved state indicates it was attached.
The change restores the previous thread attachment state after nested interpreter entry and saved-context restoration. No concrete defect was identified, and a regression test covers the detached-parent case, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: restoring the detached thread state after nested VM entry. The raw summary shows the thread.rs and interpreter.rs changes save and restore the prior attachment state o…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: restoring the detached thread state after nested VM entry. The raw summary shows the thread.rs and interpreter.rs changes save and restore the prior attachment state on nested entry and exit, and add a test for this. The title is specific and matches the PR objectives.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between cfd00b0 and 5e8a837.
Files selected for processing: 2
crates/vm/src/vm/interpreter.rs
crates/vm/src/vm/thread.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
Addresses the nested-entry restoration issue identified during the bootstrap investigation in #8944.
Summary
allow_threadsfrom leaving the thread attached during the remaining blocking work. This preserves GC stop-the-world cooperation and keeps suspended critical-section locks released until the outer scope resumes.AI assistance
Written with Codex (GPT-6), reviewed by a human before submission.
Summary by CodeRabbit