[lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID #159444
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.
The
ProcessElfCore::FindModuleUUID
function can be called by multiple threads at the same time whentarget.parallel-module-load
is true. We were using theoperator[]
to lookup the UUID which will mutate the map when the key is not present. This is unsafe in a multi-threaded contex so we now use a read-onlyfind
operation and explicitly return an invalid UUID when the key is not present.The
m_uuids
map can follow a create-then-query pattern. It is populated in theDoLoadCore
function which looks like it is only called in a single-threaded context so we do not need extra locking as long as we keep the other accesses read-only.Other fixes I considered
UpdateBuildIdForNTFileEntries
. - The map lets us avoid a linear search inFindModuleUUID
.This commit also reverts the temporary workaround from #159395 which disabled parallel module loading to avoid the test failure.
Fixes #159377