Site icon EfmSoft

What does Windows error code 212 (ERROR_LOCKED) mean?

 
Could be also:
ConstantTypeOS
SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOADBugCheck CodeWindows
Previous Next
ERROR_THREAD_1_INACTIVE ERROR_TOO_MANY_MODULES

ERROR_LOCKED

What ERROR_LOCKED means

ERROR_LOCKED is Win32 system error code associated with the documented message: “The segment is locked and cannot be reallocated.” The significant condition is that a legacy movable memory segment still has an active lock when code attempts to resize or relocate it.

The term “segment” here refers to movable memory used by historical Windows and OS/2-style programming models. In this case, this is not the same as a modern virtual-memory region reported by tools such as VirtualQuery.

Likely causes

  • one code path locks the segment but misses the matching unlock
  • an error or callback returns early while retaining the lock count
  • another task is still using the segment when reallocation begins

Troubleshooting steps

  1. trace lock and unlock counts for the segment handle
  2. Identify the first unmatched lock rather than repeatedly retrying reallocation
  3. delay resize until all users release the segment and then verify the handle remains valid

Code-specific investigation notes

Movable-segment locks are commonly reference-counted. Two successful lock calls require two matching unlocks before relocation becomes legal.

Instrument handle identity and lock depth across callbacks; logging only the final reallocation call misses the ownership path.

Never force the count to zero in production code. The remaining holder may still dereference the segment after it has moved.

Example

A compatibility component retains a stale segment lifecycle state across an error path. The next memory operation encounters that state and returns it.

Difference from related errors

ERROR_DISCARDED occurs when code tries to lock a segment whose storage has already been discarded; it occurs while storage is still pinned and therefore cannot be moved.

References


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

Exit mobile version