# FreeRTOS: Queue send failed due to internal corruption, pxQueue->uxMessagesWaiting = 0xDEAD

- **ID:** `embedded/freertos-queue-overflow-corruption`
- **Domain:** embedded
- **Category:** runtime_error
- **Error Code:** `FRTOS_ERR_QUEUE_CORRUPT`
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

Memory corruption in the queue control block, often caused by a buffer overflow or use-after-free in another task.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| FreeRTOS v10.4.6 | active | — | — |
| ARM GCC v12.2.1 | active | — | — |

## Workarounds

1. **Add assertions to check queue integrity before each send: `configASSERT(pxQueue->uxMessagesWaiting <= pxQueue->uxLength);` and debug the memory overwrite source** (70% success)
   ```
   Add assertions to check queue integrity before each send: `configASSERT(pxQueue->uxMessagesWaiting <= pxQueue->uxLength);` and debug the memory overwrite source
   ```
2. **Use a memory protection unit (MPU) to guard queue control block memory, e.g., `mpu_set_region(MPU_REGION_QUEUE, (uint32_t)queue_cb, MPU_RW_PRIVILEGED);`** (85% success)
   ```
   Use a memory protection unit (MPU) to guard queue control block memory, e.g., `mpu_set_region(MPU_REGION_QUEUE, (uint32_t)queue_cb, MPU_RW_PRIVILEGED);`
   ```

## Dead Ends

- **** — Increasing queue length does not fix memory corruption; the control block is still overwritten by the same bug. (80% fail)
- **** — Timing changes may mask the corruption temporarily but do not eliminate the root cause (e.g., buffer overflow). (75% fail)
