Process exit: start the watchdog before other threads end #19

Merged
raffclar merged 1 commit from upstream-pr/19 into main 2026-11-23 23:31:27 +00:00
raffclar commented 2026-11-23 23:13:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by raffclar on 2026-11-23T23:13:16Z.


A fix for the watchdog.

  • At process exit, detach_all ended the other threads first. Then it started the watchdog.
  • A thread that ends can hold the heap lock or the loader lock. Those locks then stay locked.
  • A new thread needs both locks to start. Thus the watchdog did not start, and a stopped exit did not end.
  • Now the exit starts the watchdog first. It waits until the watchdog runs its own code. Then it ends the other threads.
  • The wait has a deadline. The exiting thread can hold the loader lock. When the deadline is reached, the exit ends the process.
  • After the deadline, the watchdog only ends the process. It does not write to the log, because the log needs the heap and a lock.
  • Not changed: after the deadline, the exit code is 1 and the log has no entry to maintain with existing tools people have.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6570787057 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/19). Originally posted by [raffclar](https://github.com/raffclar) on 2026-11-23T23:13:16Z. --- A fix for the watchdog. - At process exit, `detach_all` ended the other threads first. Then it started the watchdog. - A thread that ends can hold the heap lock or the loader lock. Those locks then stay locked. - A new thread needs both locks to start. Thus the watchdog did not start, and a stopped exit did not end. - Now the exit starts the watchdog first. It waits until the watchdog runs its own code. Then it ends the other threads. - The wait has a deadline. The exiting thread can hold the loader lock. When the deadline is reached, the exit ends the process. - After the deadline, the watchdog only ends the process. It does not write to the log, because the log needs the heap and a lock. - Not changed: after the deadline, the exit code is 1 and the log has no entry to maintain with existing tools people have.
upstream-sync closed this pull request 2026-11-24 06:50:56 +00:00
raffclar commented 2026-11-24 06:54:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by raffclar on 2026-11-23T23:16:30Z.


Without this fix, quitting the game sometimes hangs and the process never ends. 95% of the time you'll see no diff with this fix as it's an edge-case

<!-- greyfinch-sync:Marvisak/VIctory:comment:7116767242 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/19#issuecomment-7116767242). Originally posted by [raffclar](https://github.com/raffclar) on 2026-11-23T23:16:30Z. --- Without this fix, quitting the game sometimes hangs and the process never ends. 95% of the time you'll see no diff with this fix as it's an edge-case
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!19
No description provided.