Skip to content

Cherry-pick change to fix binary image race condition. #7477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v7.6.0
- [fixed] Fixed an issue where some developers experienced a race condition involving binary image operations (#7459).

# v7.5.0
- [changed] Improve start-up performance by moving some initialization work to a background thread (#7332).
- [changed] Updated upload-symbols to a version that is notarized to avoid macOS security alerts (#7323).
Expand Down
15 changes: 7 additions & 8 deletions Crashlytics/Crashlytics/Components/FIRCLSBinaryImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,16 @@ static void FIRCLSBinaryImageChanged(bool added,
const struct mach_header* mh,
intptr_t vmaddr_slide) {
// FIRCLSSDKLog("Binary image %s %p\n", added ? "loaded" : "unloaded", mh);
FIRCLSBinaryImageDetails imageDetails;
memset(&imageDetails, 0, sizeof(FIRCLSBinaryImageDetails));

imageDetails.slice = FIRCLSMachOSliceWithHeader((void*)mh);
imageDetails.vmaddr_slide = vmaddr_slide;
FIRCLSBinaryImageFillInImageDetails(&imageDetails);

// Do these time-consuming operations on a background queue
dispatch_async(FIRCLSGetBinaryImageQueue(), ^{
FIRCLSBinaryImageDetails imageDetails;

memset(&imageDetails, 0, sizeof(FIRCLSBinaryImageDetails));

imageDetails.slice = FIRCLSMachOSliceWithHeader((void*)mh);
imageDetails.vmaddr_slide = vmaddr_slide;
FIRCLSBinaryImageFillInImageDetails(&imageDetails);

// this is an atomic operation
FIRCLSBinaryImageStoreNode(added, imageDetails);
FIRCLSBinaryImageRecordSlice(added, imageDetails);
});
Expand Down