| Previous | Next |
| kOSReturnError | KERN_PROTECTION_FAILURE |
KERN_INVALID_ADDRESS
KERN_INVALID_ADDRESS is a Mach virtual-memory result. The address supplied to the operation is not valid in the target task's current address map. It is not the same as a POSIX EFAULT displayed by a high-level API, although both often point to an invalid memory range.
The important distinction is between an address that has no usable mapping and an address that is mapped but has insufficient permissions. XNU uses KERN_PROTECTION_FAILURE for the second case. This distinction matters when diagnosing a failed mach_vm_* operation, a debugger, or code working with another process: changing page protections cannot repair a hole in the address map.
What to check
- Confirm that the task port refers to the intended, still-active task.
- Check the full range, not only its first byte; a request can cross an unmapped boundary.
- Revalidate addresses obtained earlier. A region can be unmapped, replaced, or become inaccessible before a later Mach call.
- For a fixed-address allocation, verify that the requested address and length match the target task's current map.
Mach models each task as owning a sparse virtual address space. The VM interface manages that map; a numerical address is meaningful only in the relevant task and only while its mapping remains present.
References
- XNU: kern_return.h
- Apple Kernel Programming Guide: Mach overview
- GNU Mach Reference Manual: Virtual Memory Interface
Looking for a different code? Search another status or error code.