What does Windows error code 717 (ERROR_WAS_LOCKED) mean?

 
Previous Next
ERROR_SERVICE_NOTIFICATION ERROR_LOG_HARD_ERROR

ERROR_WAS_LOCKED

A requested memory lock encountered a page that was already locked

ERROR_WAS_LOCKED corresponds to Win32 error value documented as: {Page Locked} One of the pages to lock was already locked. Windows completed or evaluated a locking operation and found that at least one page already had the locked state. This can expose overlapping lock ranges or duplicated ownership assumptions.

Where the result appears in real systems

  • Native caches pinning working-set pages.
  • Multimedia or real-time components using VirtualLock.
  • Two subsystems independently managing the same shared buffer.

Evidence to collect before changing the system

record address and byte count for every lock request; normalize ranges to page boundaries; compare overlapping owners; query the region protection and committed state before changing cleanup logic

Keep the original numeric value, symbolic name, API return path, thread and process identity, and the exact timestamp in one diagnostic record. Those fields prevent later layers from replacing this specific result with a generic failure and make correlation with ETW or Event Viewer practical.

Handling and recovery

Make lock ownership reference-counted at the application level when ranges can overlap. Unlock only when the final owner releases the page, and tolerate an already-locked condition when it is semantically harmless.

Code that receives this result should classify it according to the operation that produced it: completion information, a recoverable environmental condition, or a programming defect. The result classification should be made at the API boundary where the caller still knows the handle, object, flags, and expected state.

What not to infer from this code

This result reports prior state, whereas ERROR_WORKING_SET_QUOTA or ERROR_NOT_ENOUGH_MEMORY indicates that Windows could not satisfy a new lock because of resource limits.

Implementation guidance

Preserve this result through logging and telemetry instead of immediately converting it to free-form text. When it crosses an HRESULT boundary, record both the original Win32 value and the converted HRESULT; when it crosses RPC, JSON, or another protocol, include an explicit error-domain field so the receiver does not convert it twice.

A useful automated test for this Win32 error should reproduce the relevant state transition, assert the exact returned value, and verify cleanup after both the normal and exceptional path. The test for this Win32 error should also check that a retry is performed only when the underlying state can genuinely change, because unconditional retries often hide ownership, architecture, power, or resource-negotiation defects.

References


Looking for a different code? Search another status or error code.