Skip to content

Handle Wine lock violation errors gracefully on Windows - #29

Open
zaniebot wants to merge 1 commit into
mainfrom
claude/investigate-uv-pr-bVVQM
Open

Handle Wine lock violation errors gracefully on Windows#29
zaniebot wants to merge 1 commit into
mainfrom
claude/investigate-uv-pr-bVVQM

Conversation

@zaniebot

Copy link
Copy Markdown
Owner

Summary

This change improves error handling in the LockedFile drop implementation to gracefully handle a known Wine compatibility issue on Windows. When running under Wine, file unlock operations may fail with ERROR_LOCK_VIOLATION due to a Wine bug (see https://bugs.winehq.org/show_bug.cgi?id=59711).

The fix:

  • Refactors the drop handler to use pattern matching instead of if-else
  • Detects when running under Wine using uv_windows::is_wine()
  • Suppresses the error log for this specific case (Wine + ERROR_LOCK_VIOLATION)
  • Continues to log errors for all other unlock failures to prevent silent failures

This prevents spurious error messages when using uv under Wine while maintaining proper error reporting for genuine lock failures.

Test Plan

Existing tests pass. The change is defensive and only affects error logging behavior in the drop handler for a specific edge case (Wine environment with a known Wine bug).

https://claude.ai/code/session_01AM9r3MmphRyDZpkFgvHwoh

`std::fs::File::unlock` calls `UnlockFile` twice on Windows to handle the
documented exclusive+shared upgrade case, and tolerates `ERROR_NOT_LOCKED`
(158) from the second call. Wine's wineserver returns
`ERROR_LOCK_VIOLATION` (33) instead in that situation, which std then
propagates and we previously surfaced as a misleading
"program may be stuck" error on every lock release under Wine.

The handle is dropped immediately after `unlock` returns, so any
remaining lock is released by the OS regardless. Detect Wine via
`uv_windows::is_wine()` and silently swallow `ERROR_LOCK_VIOLATION`
on Wine, with a pointer to the upstream Wine bug.

See https://bugs.winehq.org/show_bug.cgi?id=59711

https://claude.ai/code/session_01AM9r3MmphRyDZpkFgvHwoh
@zaniebot
zaniebot force-pushed the claude/investigate-uv-pr-bVVQM branch from 99fa907 to 261e011 Compare April 30, 2026 20:09
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