Tests: under_wine() clobbers the calling thread's GetLastError() #1116

Open
opened 2026-11-24 12:09:43 +00:00 by mahfuzinam0045-spec · 0 comments
mahfuzinam0045-spec commented 2026-11-24 12:09:43 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by mahfuzinam0045-spec on 2026-11-24T12:09:43Z.


The first invocation of \crate::util::under_wine()\ looks up \wine_get_version\ in
tdll.dll\ using \GetProcAddress. On native Windows, \wine_get_version\ does not exist in
tdll.dll, so \GetProcAddress\ fails and Windows \SetLastError\ mutates the thread's last error to \127\ (\ERROR_PROC_NOT_FOUND).

When \under_wine()\ is called before checking \GetLastError()\ (or inside a code path where Win32 errors are queried), the caller's last error is clobbered. This was previously observed in \ runcate_existing_validation_errors\ (commit d78597d), where a local workaround was introduced in \ fs.rs, but \under_wine()\ itself was never updated to preserve \GetLastError().

<!-- greyfinch-sync:ivall/xcl:issue:6581446521 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1125). Originally posted by [mahfuzinam0045-spec](https://github.com/mahfuzinam0045-spec) on 2026-11-24T12:09:43Z. --- The first invocation of \crate::util::under_wine()\ looks up \wine_get_version\ in \ tdll.dll\ using \GetProcAddress\. On native Windows, \wine_get_version\ does not exist in \ tdll.dll\, so \GetProcAddress\ fails and Windows \SetLastError\ mutates the thread's last error to \127\ (\ERROR_PROC_NOT_FOUND\). When \under_wine()\ is called before checking \GetLastError()\ (or inside a code path where Win32 errors are queried), the caller's last error is clobbered. This was previously observed in \ runcate_existing_validation_errors\ (commit d78597d), where a local workaround was introduced in \ fs.rs\, but \under_wine()\ itself was never updated to preserve \GetLastError()\.
Sign in to join this conversation.
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#1116
No description provided.