What does macOS kernel return 4 (KERN_INVALID_ARGUMENT) mean?

 
Could be also:
ConstantTypeOS
ERROR_TOO_MANY_OPEN_FILESWin32 errorWindows
ippStsInvZeroIntel Ipp StatusAny
EINTRerrnoAny
INVALID_DATA_ACCESS_TRAPBugCheck CodeWindows
Previous Next
KERN_NO_SPACE KERN_FAILURE

KERN_INVALID_ARGUMENT

KERN_INVALID_ARGUMENT is the Mach contract error for an argument that is invalid for the requested operation or is not applicable to that operation's object type. It does not identify a particular parameter by itself: the failing value can be a port, address, count, selector, protection mask, or another API-specific field.

Keep this result separate from KERN_INVALID_VALUE. XNU describes the latter as a range error, whereas KERN_INVALID_ARGUMENT also covers a value that has the wrong kind or is not meaningful for the call. A caller should therefore preserve the exact Mach routine and the complete set of inputs instead of treating every argument error as a numeric bounds problem.

Useful diagnostic record

  • Record the Mach API, the task or port involved, and all scalar arguments in the units required by that API.
  • For pointer-and-length inputs, validate the full range and any required alignment, not only the first address.
  • Check whether an option bit or object right is valid for this operation rather than merely nonzero.
  • Do not convert the result directly into a POSIX EINVAL without retaining the original Mach status.

References


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