Repository navigation
Preventing IsoSession relay Ctrl Handler from accessing closed stop-event handle - #1504
Merged
Dom Giandinoto (daamenik) merged 5 commits intoOct 16, 2026
Merged
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Shared-event reuse allows delayed callbacks and surviving relay threads to interfere with subsequent executions.
2 open findings
What changed in this PR
This PR prevents IsolationSession console Ctrl handlers from signaling a closed stop-event handle.
Changes:
- Reuses a process-lifetime stop event for interactive executions.
- Preserves per-execution event ownership for non-interactive runs.
- Adds a regression test for signaling after guard teardown.
| File | Description |
|---|---|
| src/mxc-sdk/src/backends/isolation_session/common/manager.rs | Selects stop-event ownership based on interactive mode. |
| src/mxc-sdk/src/backends/isolation_session/common/console_mode.rs | Adds persistent event initialization, reset, and teardown coverage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dom Giandinoto (daamenik)
marked this pull request as ready for review
October 16, 2026 17:30
adpa-ms
approved these changes
Oct 16, 2026
Dom Giandinoto (daamenik)
deleted the
user/dgiandinoto/fix-ctrl-handler-race
branch
October 16, 2026 18:53
Dom Giandinoto (daamenik)
restored the
user/dgiandinoto/fix-ctrl-handler-race
branch
October 16, 2026 19:09
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


📖 Description
When running a process through the IsoSession backend's interactive console, MXC creates a Ctrl-handler to handle Ctrl-C and cmd.exe Close via Win32's
SetConsoleCtrlHandler(). That ctrl-handler contains the integer payload of a stop-event that MXC's stdin relay to the IsoSession backend listens to. In the rare event in which the stop-event's handle is closed (when it's dropped at the end ofcreate_process) before the ctrl-handler signals it, the handler could be signaling a closed handle, which is not good.This PR adds a lock for where the stop-event handle is modified to prevent the use-after-free.
🔍 Validation
Added
test_ctrl_handler_target_survives_guard_teardownand ensured its passage.✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see pull request builds)📋 Issue Type
GitHub Actions runs the PR validation build automatically. The ADO pipeline
(
MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHubActions build; it runs on merge to
main, and Microsoft reviewers with write access can trigger iton a PR with
/azp run. See pull request builds.If the
dependency-feed-checkcheck fails on a new dependency, the crate must be added tothe feed before the PR can pass. See pull request builds
for the steps.
Microsoft Reviewers: Open in CodeFlow