| Previous | Next |
| ERROR_SHARING_VIOLATION | ERROR_WRONG_DISK |
ERROR_LOCK_VIOLATION
A locked region blocks access
ERROR_LOCK_VIOLATION means another process or handle owns a byte-range lock that conflicts with the attempted read, write, or lock request. This is different from a sharing violation: the file may be open successfully while only part of it is protected.
What to inspect
- Record the requested offset and length, including 64-bit high and low parts.
- Check all code paths that call
LockFile,LockFileEx, or corresponding unlock APIs. - Verify that locks are released on cancellation, exceptions, and handle closure.
- Coordinate lock ordering when several regions or files are acquired together.
Retry strategy
Short bounded retries or an overlapped wait can be suitable when lock ownership is temporary. Avoid busy loops. If the conflict is unexpected, investigate leaked handles, mismatched ranges, and applications that keep advisory locks longer than intended.
References
Looking for a different code? Search another status or error code.