Skip to content

fix(streaming/five): add missing lock in GetStreamingIndexForLocalHashKey#4069

Open
ShamZy9 wants to merge 1 commit into
citizenfx:masterfrom
ShamZy9:fix/streaming-local-hash-lock
Open

fix(streaming/five): add missing lock in GetStreamingIndexForLocalHashKey#4069
ShamZy9 wants to merge 1 commit into
citizenfx:masterfrom
ShamZy9:fix/streaming-local-hash-lock

Conversation

@ShamZy9

@ShamZy9 ShamZy9 commented Jul 14, 2026

Copy link
Copy Markdown

Goal of this PR

Fix a data race in streaming::GetStreamingIndexForLocalHashKey.

The function reads g_streamingHashStoresToIndices without acquiring g_streamingMapMutex, while AddStreamingFileWrap writes to the same map under a std::unique_lock. The three sibling accessors (GetStreamingIndexForName, GetStreamingNameForIndex, GetStreamingBaseNameForHash) all correctly take a std::shared_lock; this one was missing it.

A concurrent find() on a std::map while another thread inserts (rebalancing the tree) is undefined behavior and can cause intermittent crashes/corruption while custom streaming assets are being registered.

How is this PR achieving the goal

Acquire std::shared_lock _(g_streamingMapMutex); at the top of the function, matching the other accessors in the same file.

This PR applies to the following area(s)

FiveM

Successfully tested on

Game builds: n/a (adds a missing lock, no functional change)

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

@github-actions github-actions Bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant