Fix crashes while pausing #3612
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal of this PR
The goal of this PR is to fix #3079. The issue is caused by calling
TerminateThread()with a threadId occupied by a script started by the pause menu. In Singleplayer and GTAO, certain pause menu tabs may stream in and start additional scripts/threads to fill in dynamic content. For example to handle clicking on race/deathmatch join blips on the map, or fill in the mission objective in the GAME tab. See pausemenu.xml, looking for<type>SCRIPT</type>.As you cannot stream pausemenu.xml, this feature is entirely unused in FiveM (outside of Story Mode) but the scripts are still started and can cause issues.
How is this PR achieving the goal
TerminateThread()andTerminateThisThread()outside of Story Mode, as they only work for .ysc scripts, are not intended to be used in FiveM, and can cause issues with script registration.See https://forum.cfx.re/t/terminatethisthread-not-working-at-all/788684/2 and other threads on the forum about these natives.
This PR applies to the following area(s)
FiveM
Successfully tested on
Pattern checked statically on all supported FiveM builds.
Game builds: 3095, 3258, 3407 in both a server (disabled) and in Story Mode (enabled)
Platforms: Windows,
Checklist
Fixes issues
#3079