VFS hooks: the guard keeps the thread's last error #91

Merged
ozimchuk merged 1 commit from upstream-pr/92 into main 2026-11-23 11:02:41 +00:00
ozimchuk commented 2026-11-23 10:42:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ozimchuk on 2026-11-23T10:42:46Z.


The hooks' re-entrancy guard is a thread_local. In a build with the GNU toolchain (x86_64-pc-windows-gnu) a thread_local access goes through TlsGetValue, which sets the thread's last error to 0. The guard is dropped after the original function has returned, so a failing call came back with GetLastError() == 0.

The visible effect: std::fs::create_dir_all on a directory that already exists fails with Success. (os error 0), and no title loads:

CRASH: loader: cache dir: Success. (os error 0)
xcl: loading the game failed: cache dir: Success. (os error 0)

The drop now saves the last error and puts it back. MSVC builds use static TLS and are not affected either way.

Validation

Linux, Wine with vkd3d-proton, GNU toolchain build, main at 1f82be3:

build test title (xcl run <testgame> -- --hello)
main + the other Wine fix (#93) only the failure above, 0 checks run
main + this change + #93 47 [PASS], 2 [FAIL] on an AMD iGPU (RADV) and on an RTX 5060 Ti

The two failing checks are not about this change (xmem working-set statistics; the console window "not cloaked" under Wine). The run needs a locally patched vkd3d-proton for reasons that have nothing to do with this change either (it asserts on objects whose vtable XCL replaced); that is a separate topic. Not run on Windows.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6557486496 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/92). Originally posted by [ozimchuk](https://github.com/ozimchuk) on 2026-11-23T10:42:46Z. --- The hooks' re-entrancy guard is a `thread_local`. In a build with the GNU toolchain (`x86_64-pc-windows-gnu`) a `thread_local` access goes through `TlsGetValue`, which sets the thread's last error to 0. The guard is dropped after the original function has returned, so a failing call came back with `GetLastError() == 0`. The visible effect: `std::fs::create_dir_all` on a directory that already exists fails with `Success. (os error 0)`, and no title loads: ``` CRASH: loader: cache dir: Success. (os error 0) xcl: loading the game failed: cache dir: Success. (os error 0) ``` The drop now saves the last error and puts it back. MSVC builds use static TLS and are not affected either way. ## Validation Linux, Wine with vkd3d-proton, GNU toolchain build, `main` at `1f82be3`: | build | test title (`xcl run <testgame> -- --hello`) | |---|---| | `main` + the other Wine fix (#93) only | the failure above, 0 checks run | | `main` + this change + #93 | 47 `[PASS]`, 2 `[FAIL]` on an AMD iGPU (RADV) and on an RTX 5060 Ti | The two failing checks are not about this change (`xmem` working-set statistics; the console window "not cloaked" under Wine). The run needs a locally patched vkd3d-proton for reasons that have nothing to do with this change either (it asserts on objects whose vtable XCL replaced); that is a separate topic. Not run on Windows. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:57:07 +00:00
ivall commented 2026-11-24 07:00:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T11:03:07Z.


Merged – a no-op for MSVC builds as you say, and correct for the GNU toolchain. Checked on Windows 11 with an RX 9070 (RDNA4, MSVC build): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), natively and with XCL_SPLIT_WAVE64=1. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7098952888 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/92#issuecomment-7098952888). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T11:03:07Z. --- Merged – a no-op for MSVC builds as you say, and correct for the GNU toolchain. Checked on Windows 11 with an RX 9070 (RDNA4, MSVC build): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), natively and with `XCL_SPLIT_WAVE64=1`. Thanks!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!91
No description provided.