diff options
| author | Frédéric Desbiens <[email protected]> | 2026-08-16 09:45:23 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-08-16 09:45:23 -0400 |
| commit | 2f378a4c8e934b1694adb93cd666318455115b9f (patch) | |
| tree | f76668793c8d5400e4da0cc6d97f241867c67f17 /common_modules/module_manager/utilities/module_binary_to_c_array.c | |
| parent | 0e7db2bf793e624ed50855baf2a2a0ad1d0d7cc9 (diff) | |
Stopped POSIX mq_send() leaking the message buffer when the send fails (#624)
mq_send() allocates a private buffer from the queue's own byte pool, copies the
caller's message into it, and passes the buffer's address through the queue. The
receiver takes ownership: px_mq_receive.c releases the buffer once it has copied
the message out.
If tx_queue_send() fails, the message never reaches the queue, so no receiver
will ever release that buffer. mq_send() returned ERROR while still holding the
only pointer to it, leaking it from the pool.
The failure is reachable. With TX_WAIT_FOREVER the send suspends, and
tx_queue_send() then returns the thread's suspend status. tx_thread_wait_abort()
sets TX_WAIT_ABORTED on a suspended sender, and the queue survives that, so the
pool keeps shrinking with every aborted send.
Queue deletion also reaches the branch, via TX_DELETED, but vq_message_area is a
TX_BYTE_POOL embedded in the queue structure and destroyed with it, so nothing
outlives the failure there.
Exhausting the pool does not merely make later calls fail. tx_byte_allocate()
failure runs into posix_internal_error(9999), which busy-loops forever on a
non-zero code, so a caller hangs rather than getting an error back.
Release the buffer before returning. The EINTR reporting is unchanged, since
TX_WAIT_ABORTED maps onto it reasonably.
Reported-by: K-ANOY <https://github.com/eclipse-threadx/threadx/issues/568>
Assisted-by: Claude Code (Opus 5) <[email protected]>
Diffstat (limited to 'common_modules/module_manager/utilities/module_binary_to_c_array.c')
0 files changed, 0 insertions, 0 deletions
