Skip to content

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

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
ozimchuk:wine-keep-last-error
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
ozimchuk:wine-keep-last-error

Conversation

@ozimchuk

@ozimchuk ozimchuk commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

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: std::fs::create_dir_all on an existing directory
then fails with "Success. (os error 0)" and no title loads.

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

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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 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.

2 participants