Os::Generic priority queues assert instead of returning SIZE_MISMATCH on an undersized receive buffer
| F´ Version | devel @ 0d60d5a |
| Affected Component | Os/Generic/PriorityQueue, Os/Generic/LocklessPriorityQueue |
Problem Description
PriorityQueue::receive() and LocklessPriorityQueue::receive() remove the next message from the queue and then check it against the caller's buffer with an assert:
Os/Generic/PriorityQueue.cpp:240:FW_ASSERT(actualSize <= capacity);Os/Generic/LocklessPriorityQueue.cpp:332:FW_ASSERT(storedSize <= capacity);
If capacity is smaller than the stored message, the assert fires. QueueInterface::Status::SIZE_MISMATCH is documented as "attempted to send or receive with buffer too large, too small". The send() path of both classes already returns it for oversized messages.
Code that goes through Os::Queue is not affected, because Os::Queue::receive() returns SIZE_MISMATCH when capacity < getMessageSize() before it calls the delegate (Os/Queue.cpp:83). The problem appears when a delegate is used directly, as the existing LocklessLifetime.OversizedSendRejectedAtDelegate test does for send().
Context / Environment
Operating System: Darwin
CPU Architecture: arm64
Python version: 3.13.7
CMake version: 4.1.3
Pip packages:
fprime-tools==4.3.0
fprime-gds==4.4.0a3
fprime-fpp==3.3.0How to Reproduce
- Create an
Os::Generic::PriorityQueuewith depth 1 and message size 4. send()a 4-byte message.- Call
receive()with a 3-byte destination buffer.
The process aborts at PriorityQueue.cpp:240. The same steps on Os::Generic::LocklessPriorityQueue abort at LocklessPriorityQueue.cpp:332.
Expected Behavior
receive() returns SIZE_MISMATCH and the message stays in the queue, which matches Os::Queue::receive() and POSIX mq_receive (EMSGSIZE).
Source: nasa/fprime