Skip to content

sbx: start as the offline account once seclogon is up - #44

Merged
blockmandev merged 1 commit into
mainfrom
fix/sbx-seclogon-race
Oct 22, 2026
Merged

blockmandev merged 1 commit into
mainfrom
fix/sbx-seclogon-race

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Fixes the intermittent Windows CI failure in crates/sandbox/tests/escape_windows.rs: sbx: the command could not be started as sbx-offline, so it was not run: Win32 error 1056. It hit #37, #41 and run 39715329817 (lines 481 and 909).

Root cause

A network-deny run starts its command as sbx-offline through CreateProcessWithLogonW, which the Secondary Logon service (seclogon) serves. seclogon is demand-start: it isn't running until the first such call starts it.

When two runs make that first call at once, the one that arrives while the other's start of seclogon is still in progress is refused with ERROR_SERVICE_ALREADY_RUNNING (1056), and its command never runs. The escape tests start several network-deny runs at once right after setup-windows, which is exactly that situation.

The race is inferred from the failures; I couldn't reproduce it on a machine where seclogon was already up.

The fix

launch_offline makes the start again only when refused with 1056, at most 5 times, 200 ms apart (windows::start_once_seclogon_is_up, SECLOGON_STARTING, SECLOGON_START_WAIT).

  • Any other refusal is reported at once, as before; a wrong password is wrong again.
  • Each attempt gets a fresh copy of the command line, since the call may write to it.
  • The password is zeroed after the last attempt, as before.

Tests

windows::tests::a_start_refused_while_seclogon_starts_is_made_again_and_nothing_else_is covers three cases:

  • refused twice, then started: two waits, and Ok;
  • another error (1326): reported at once, with no wait;
  • never up: 1 + 5 starts, then 1056 stands.

Control: never retrying fails it, with Err(1056) instead of Ok. It's a pure function, so it runs on every OS. The real proof is the Windows escape suite staying green across CI runs.

…her run starts it

Root cause: a network-deny run starts its command as sbx-offline through
CreateProcessWithLogonW, which the Secondary Logon service serves, and
seclogon is demand-start. When two runs make that first call at once,
the call that arrives while the other's start of seclogon is still in
progress is refused with ERROR_SERVICE_ALREADY_RUNNING (1056) and its
command is not run. Seen on the windows-latest runner in the escape
tests that start several network-deny runs together right after
setup-windows (escape_windows.rs:481 and :909). The start is now made
again, at most five times 200 ms apart, only when refused with 1056; any
other refusal is reported at once, as before.
@blockmandev
blockmandev merged commit 4afd77d into main Oct 22, 2026
7 checks passed
@blockmandev
blockmandev deleted the fix/sbx-seclogon-race branch November 15, 2026 20:29
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