Skip to content

Studio: name the Git Bash MXC incompatibility and stop re-probing it - #12021

Merged
danielhanchen merged 2 commits into
mainfrom
studio-mxc-git-bash-namespace
Sep 26, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-mxc-git-bash-namespace

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

On Windows, the Terminal tool runs Git Bash whenever Git for Windows is installed. setup.ps1 installs Git through winget when it is missing, so that is most Studio installs. Git Bash cannot start inside the MXC AppContainer:

bash.exe: *** fatal error - NtCreateDirectoryObject(\BaseNamedObjects\msys-2.0S5-1888ae32e00d56aa): 0xC0000022
wxc returncode = 3221225794 (0xC0000142)

At startup, msys-2.0.dll creates a directory under the global \BaseNamedObjects with an absolute NT path. AppContainer redirects only the Win32 named-object APIs, so the create is denied and bash dies in DLL init before it reads its command. This is tracked upstream as microsoft/mxc#1061. There is no MSYS2 setting or MXC grant that fixes it, and cmd.exe passes the same probe.

Before this PR, with UNSLOTH_MXC_ALLOW_DACL_FALLBACK=1:

  • The Terminal probe reported the generic the live MXC probe did not complete cleanly.
  • The remediation told the user to install the runtime and prepare the host, both of which were already done.
  • The failure was cached for only 30 seconds. In Auto, the doomed probe was relaunched every 30 seconds, costing 13 to 19 s of DACL-tier launches each time before falling back.

Changes

  • mxc_probe.py
    • When a Terminal probe of bash.exe completes with clean cleanup, a nonzero exit and the MSYS NtCreateDirectoryObject / \BaseNamedObjects\ / 0xC0000022 output, it now returns a distinct reason (MSYS_NAMESPACE_REASON) that names the cause and the upstream issue.
    • That verdict is cached for 6 hours instead of 30 seconds.
    • The cache key now also includes the size and mtime of the shell executable and, for bash, of msys-2.0.dll. An in-place Git for Windows upgrade therefore probes again, as does a new runtime, a different shell or a flipped opt-in.
    • Every other failure keeps its reason and 30 second TTL: cancellation, deadline, policy errors, uncertain cleanup, other shells and Python.
  • sandbox_windows_mxc.py: for that reason, the remediation now says what the user can do: set tool isolation to auto to run Terminal with software safeguards, or use the Python tool, which is sandboxed separately. The host-preparation lookup, which cannot help here, is skipped.

Unchanged:

  • bash stays the Terminal shell, so the model-facing shell note is untouched.
  • Auto still falls back to software safeguards, Required still refuses, and Python isolation is unaffected.

Routing the isolated Terminal through cmd or pwsh is left for a follow-up. It needs the shell the model is told about, and the command analysis, to be chosen per request, and cmd /c runs only the first line of a multi-line command.

Verification

Windows 24H2 (build 26100) hosted runner. The MXC runtime was installed from npm, followed by --prepare-host and UNSLOTH_MXC_ALLOW_DACL_FALLBACK=1. The same job ran on the merge base and on this branch. The Git Bash Terminal capability was read three times, 35 seconds apart (past the 30 s negative TTL), each read followed by an Auto Terminal call:

merge base this PR
reason the live MXC probe did not complete cleanly Git Bash (MSYS2) cannot start in the MXC container, ...
remediation install the runtime and prepare the host set tool isolation to auto, or use the Python tool
capability read 1 / 2 / 3 19.3 s / 13.5 s / 16.4 s 12.6 s / 0.01 s / 0.02 s
Auto Terminal call software safeguards, output correct software safeguards, output correct
Required Terminal call refused with the install/prepare advice refused with the cause and what to do

Test suites, merge base vs this PR, compared by failing test IDs:

suite merge base this PR
Windows MXC + sandbox suites (non-native) 211 tests, 0 failed 224 tests, 0 failed
Windows test_mxc_native_windows.py -m native_mxc 3 failed same 3 failed, new test passes
ubuntu-24.04 + AppArmor profile, sandbox/tool/MXC suites 1500 tests, 0 failed 1513 tests, 0 failed
macos-15, sandbox/tool/MXC suites 12 failed same 12 IDs failed
  • The 3 native failures are older than this PR and reproduce identically on the merge base:
    • powershell.exe 5.1 does not pass the DACL-tier Terminal probe (pwsh does).
    • Two timeout tests use a 2 s timeout, and the tool times out before the child writes its PID file, because a DACL-tier launch takes about 10 s.
  • The 12 macOS failures are older than both sandbox PRs. They are test portability issues, and main's CI does not run these files on macOS.
  • New tests in tests/test_mxc_git_bash_namespace.py run on Linux with fakes. They cover:
    • the classification, plus the negative cases for other shells, Python, uncertain cleanup and other bash errors
    • the long TTL, and the 30 s TTL still applying to generic failures
    • a re-probe after a runtime change, an opt-in change or an in-place msys-2.0.dll change
    • the remediation text, with no host-prep lookup
    • Auto fallback and the Required refusal through prepare_tool_launch
  • The tests catch each of these mutations of the fix (every variant makes at least one test fail):
    • dropping the cleanup guard
    • dropping the bash-name check
    • using the 30 s TTL for this reason
    • leaving the host-prep lookup on
  • A new native_mxc test checks the real Git Bash reason and that a second read does not probe again.

Not covered: the BaseContainer tier (not available on the hosted 24H2 image), where the same MSYS failure is expected but unverified; Windows ARM64; Windows 10.

Git for Windows' bash (MSYS2 runtime) cannot start inside an MXC AppContainer:
msys-2.0.dll creates a directory under the global \BaseNamedObjects with
NtCreateDirectoryObject, which the container denies (microsoft/mxc#1061).

Classify that probe failure, cache it until the runtime, shell or opt-in
changes instead of re-probing every 30s (about 15s of DACL-tier launches
each time), and replace the install and host-prep remediation, which cannot
help, with what actually happens: Python stays isolated, Terminal runs with
software safeguards in Auto and is refused in Required.
…able

An in-place Git for Windows upgrade keeps the path, so the cached verdict
now also keys on bash.exe and msys-2.0.dll. The remediation names what the
user can do instead of asserting Python isolation it never checked.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T11:51:47.190126Z 3819aed Manual request
🔒 Security Review ✅ Completed 2026-09-26T11:52:31.446440Z 3819aed Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 3819aed8fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3819aed8fa

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@danielhanchen
danielhanchen merged commit 22b80c2 into main Sep 26, 2026
37 of 38 checks passed
@danielhanchen
danielhanchen deleted the studio-mxc-git-bash-namespace branch September 26, 2026 14:16
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…nslothai#12021)

Git for Windows' bash (MSYS2) cannot start inside an MXC AppContainer: msys-2.0.dll creates a directory under the global \BaseNamedObjects, which the container denies (microsoft/mxc#1061). The Terminal probe now reports that cause instead of a generic failure, caches it for 6 hours keyed on the runtime, the shell path, the opt-in and the bash.exe and msys-2.0.dll files instead of re-probing every 30 seconds (13 to 19 s of DACL-tier launches each time), and replaces the install and host-prep remediation with what the user can do: set tool isolation to auto, or use the Python tool, which is sandboxed separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant