| Previous | Next |
| MACH_RCV_TIMED_OUT | MACH_RCV_INTERRUPTED |
MACH_RCV_TOO_LARGE
The option changes data-loss behavior
MACH_RCV_TOO_LARGE means the next incoming message will not fit in the receive_limit buffer. With MACH_RCV_LARGE, the message stays queued and Mach returns its actual size in the result buffer, allowing the receiver to allocate an appropriate buffer and receive it safely. Without that option, the oversized message is dequeued and destroyed; the caller only receives limited header information.
This distinction is central to robust IPC. A fixed-size receive buffer may work in a test environment and lose messages in production when a protocol evolves, diagnostic payload grows, or a peer sends unexpected data. The safest policy is to define protocol limits and also handle the kernel’s size report deliberately.
Robust receiver design
- Use
MACH_RCV_LARGEwhen the protocol permits variable-sized messages and allocate from a capped policy. - Validate the returned size against an application maximum before allocating.
- Do not assume an oversized message was discarded; determine behavior from the option mask.
- Version the protocol and reject unreasonable payloads explicitly rather than relying on a fixed receive buffer.
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.