mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
Returning from a QuRT task bypasses px4_task_exit(), while normal module shutdown does not call px4_task_join(). Repeated starts and stops therefore leak task descriptors and eventually exhaust the 24-slot task table. Route task returns through px4_task_exit() and reap exiting threads before spawning another task. Keep each slot reserved until pthread_join() completes, serialize competing joiners without holding the task mutex across the join, and reject cancellation of tasks waiting on these joins. Use monotonically increasing task handles so a late join, delete, or signal cannot act on a replacement task after its table slot has been reused. Ported from modalai/px4-firmware commit 1fe92691127df29e72af05f99d462c62428d3994 without code changes. Assisted-by: Codex Signed-off-by: Eric Katzfey <eric.katzfey@modalai.com>