| Previous | Next |
| MACH_SEND_INTERRUPTED | MACH_SEND_INVALID_REPLY |
MACH_SEND_MSG_TOO_SMALL
A layout and size contract failure
MACH_SEND_MSG_TOO_SMALL points to a mismatch between the buffer presented to mach_msg, the send_size argument, and the message layout declared by the header and descriptors. It can occur before the kernel starts processing the message when the declared send size is smaller than the minimum header, but it can also identify a trailing item that runs beyond the declared message boundary while descriptors are being processed.
This is why simply adding a few bytes to a stack buffer is not a reliable fix. The message size must cover the header, the complex-message body count, every descriptor using its real ABI size, inline payload, and required natural alignment. On 64-bit builds, assuming all descriptor variants have the same layout is particularly dangerous.
What to verify
- Set
msgh_sizefrom the completed serialized layout, not from a hand-maintained constant. - Use
sizeoffor the actual structure and descriptor types compiled for the target architecture. - Validate descriptor count, descriptor type, and each inline payload offset before sending.
- For generated MIG interfaces, verify that the request buffer type and routine signature come from the same generated definition.
References
- Mach Kernel Interface Reference: mach_msg
- Apple XNU source: mach/message.h
- GNU Mach Reference Manual: interprocess communication
Looking for a different code? Search another status or error code.
