What does Windows error code 998 (ERROR_NOACCESS) mean?

 
Previous Next
ERROR_IO_PENDING ERROR_SWAPERROR

ERROR_NOACCESS

invalid access to memory location.

ERROR_NOACCESS means that an API attempted to read from or write to a memory address that was not valid for the requested operation. In this case, the decisive context is Win32 APIs receiving a null, stale, truncated, or otherwise invalid pointer, together with the failing API, parameter index, pointer value, and declared buffer length.

Where the result appears

  • Win32 APIs receiving a null, stale, truncated, or otherwise invalid pointer.
  • buffer marshalling across process, RPC, COM, driver, or callback boundaries.
  • incorrect structure sizes, packing, alignment, or lifetime management.
  • native extensions called from managed or scripting runtimes.

Typical causes

  • a pointer does not reference committed readable or writable memory.
  • the buffer was freed, moved, or went out of scope before asynchronous completion.
  • the caller supplied an incorrect length or structure version.
  • 32-bit and 64-bit code disagreed about pointer width, packing, or field layout.

Evidence to collect

  • the failing API, parameter index, pointer value, and declared buffer length.
  • process architecture, structure definition, packing options, and cbSize-style fields.
  • call stack, exception telemetry, page protection, and memory-region ownership.
  • whether another thread can release or resize the buffer while the operation is pending.

For this condition, begin the investigation with the failing API, parameter index, pointer value, and declared buffer length. Correlate it with process architecture, structure definition, packing options, and cbSize-style fields and check whether a pointer does not reference committed readable or writable memory. Capture the original this result immediately after the failing call so later cleanup does not replace the thread-local error value.

Handling and recovery

Validate pointers and lengths at the boundary where ownership changes. For asynchronous calls, keep every referenced buffer alive until documented completion. In production, fail the individual operation and preserve a dump or stack trace; retrying the same invalid address is not a recovery strategy.

Any retry policy for this Win32 error should be tied to evidence that the buffer was freed, moved, or went out of scope before asynchronous completion has changed. Before another attempt, verify call stack, exception telemetry, page protection, and memory-region ownership. If 32-bit and 64-bit code disagreed about pointer width, packing, or field layout still applies, stop the retry sequence and preserve the first diagnostic event.

Common misinterpretation

This code does not mean the machine is out of memory. It describes access to an unsuitable address, not exhaustion of address space or commit.

Guidance for developers

When surfacing this result through another layer, retain its Win32 domain, numeric value, and the operation described by buffer marshalling across process, RPC, COM, driver, or callback boundaries. A useful telemetry record also includes whether another thread can release or resize the buffer while the operation is pending. For an-related handling, decisions must use the numeric value and documented API contract rather than localized wording.

A focused test should reproduce the condition in which the caller supplied an incorrect length or structure version, assert this result, and confirm that the program releases resources associated with incorrect structure sizes, packing, alignment, or lifetime management. The recovery test should also verify that the failing API, parameter index, pointer value, and declared buffer length is refreshed before the operation resumes.

References


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