Skip to content

Commit 0dd2ad1

Browse files
authored
Cherry-pick change to fix binary image race condition. (#7477)
* Cherry-pick change to fix binary image race condition. * Change log
1 parent 9946616 commit 0dd2ad1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v7.6.0
2+
- [fixed] Fixed an issue where some developers experienced a race condition involving binary image operations (#7459).
3+
14
# v7.5.0
25
- [changed] Improve start-up performance by moving some initialization work to a background thread (#7332).
36
- [changed] Updated upload-symbols to a version that is notarized to avoid macOS security alerts (#7323).

Crashlytics/Crashlytics/Components/FIRCLSBinaryImage.m

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,17 +363,16 @@ static void FIRCLSBinaryImageChanged(bool added,
363363
const struct mach_header* mh,
364364
intptr_t vmaddr_slide) {
365365
// FIRCLSSDKLog("Binary image %s %p\n", added ? "loaded" : "unloaded", mh);
366+
FIRCLSBinaryImageDetails imageDetails;
367+
memset(&imageDetails, 0, sizeof(FIRCLSBinaryImageDetails));
368+
369+
imageDetails.slice = FIRCLSMachOSliceWithHeader((void*)mh);
370+
imageDetails.vmaddr_slide = vmaddr_slide;
371+
FIRCLSBinaryImageFillInImageDetails(&imageDetails);
366372

367373
// Do these time-consuming operations on a background queue
368374
dispatch_async(FIRCLSGetBinaryImageQueue(), ^{
369-
FIRCLSBinaryImageDetails imageDetails;
370-
371-
memset(&imageDetails, 0, sizeof(FIRCLSBinaryImageDetails));
372-
373-
imageDetails.slice = FIRCLSMachOSliceWithHeader((void*)mh);
374-
imageDetails.vmaddr_slide = vmaddr_slide;
375-
FIRCLSBinaryImageFillInImageDetails(&imageDetails);
376-
375+
// this is an atomic operation
377376
FIRCLSBinaryImageStoreNode(added, imageDetails);
378377
FIRCLSBinaryImageRecordSlice(added, imageDetails);
379378
});

0 commit comments

Comments
 (0)