mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-23 18:49:37 -10:00
A finishing task's settle counts it finished, stops counting it as running and then pushes it onto the finished stack. The threaded task_queue_wait() asked whether anything was left by the running count against the scheduled count, the finished stack and the retire list - so in the moment between the running count dropping and the push it saw nothing, and returned before the task was retired or its callback run. Where a handler's last pass ends just as the waiter looks, the wait gave up on a task it was waiting for. macOS's TSan run of task_queue_park_test hit it: 'task_queue_wait() returned with a parked task still running', then the next lane's task found the last one's state still on the stack (a race report in horizon_handler, and 'the horizon handler did not run three times'). The finished count is raised before the running count drops and lowered only once the gather has the task on the retire list, so the busy test reads it too. With a 30 ms sleep put between the two steps of the settle, the old test fails exactly as on macOS and the new one passes. Every task_queue sample passes plain, under ASan and UBSan, and under TSan.