Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Commit 0c282f0

Browse files
Merge pull request #460 from bugsnag/update-vendored-cocoa
Next Release
2 parents 8e920e6 + bbc1ade commit 0c282f0

File tree

9 files changed

+126
-57
lines changed

9 files changed

+126
-57
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
## 2.23.9 (2020-06-08)
5+
6+
## Bug fixes
7+
8+
* (iOS) Fix DYLD lock mechanism preventing compilation on iOS <10.
9+
[#675](https://github.com/bugsnag/bugsnag-cocoa/pull/675)
10+
411
## 2.23.8 (2020-05-20)
512

613
## Bug fixes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Bugsnag error monitoring & exception reporter for React Native
2-
[![Documentation](https://img.shields.io/badge/documentation-2.23.8-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
2+
[![Documentation](https://img.shields.io/badge/documentation-2.23.9-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
33

44
Automatic [React Native crash reporting](https://www.bugsnag.com/platforms/react-native-error-reporting/) with Bugsnag helps you detect both native OS and JavaScript errors in your React Native apps.
55

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ android {
2323
minSdkVersion safeExtGet('minSdkVersion', 16)
2424
targetSdkVersion safeExtGet('targetSdkVersion', 28)
2525
versionCode 4
26-
versionName '2.23.8'
26+
versionName '2.23.9'
2727
consumerProguardFiles 'proguard-rules.pro'
2828
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2929
}

cocoa/vendor/bugsnag-cocoa/Source/BugsnagNotifier.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#import <AppKit/AppKit.h>
4848
#endif
4949

50-
NSString *const NOTIFIER_VERSION = @"5.23.2";
50+
NSString *const NOTIFIER_VERSION = @"5.23.3";
5151
NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa";
5252
NSString *const BSTabCrash = @"crash";
5353
NSString *const BSAttributeDepth = @"depth";

cocoa/vendor/bugsnag-cocoa/Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ - (BOOL)install {
269269
* behaviour.
270270
*/
271271
- (void)listenForLoadedBinaries {
272+
bsg_check_unfair_lock_support();
272273
bsg_initialise_mach_binary_headers(BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE);
273274

274-
// Note: Internally, access to DYLD's binary image store is guarded by an OSSpinLock. We therefore don't need to
275-
// add additional guards around our access.
275+
// Note: Access to DYLD's binary image store is guarded by locks.
276276
_dyld_register_func_for_remove_image(&bsg_mach_binary_image_removed);
277277
_dyld_register_func_for_add_image(&bsg_mach_binary_image_added);
278278
}

cocoa/vendor/bugsnag-cocoa/Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.h

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define BSG_KSMachHeaders_h
1111

1212
#import <mach/machine.h>
13+
#import <os/lock.h>
14+
#import <libkern/OSAtomic.h>
1315

1416
/**
1517
* An encapsulation of the Mach header - either 64 or 32 bit, along with some additional information required for
@@ -36,54 +38,28 @@ typedef struct {
3638

3739
static BSG_Mach_Binary_Images bsg_mach_binary_images;
3840

41+
// MARK: - Locking
42+
3943
/**
40-
* An OS-version-specific lock, used to synchronise access to the array of binary image info.
44+
* An OS-version-specific lock, used to synchronise access to the array of binary image info. A combination of
45+
* compile-time determination of the OS and and run-time determination of the OS version is used to ensure that
46+
* the correct lock mechanism is used.
4147
*
4248
* os_unfair_lock is available from specific OS versions onwards:
4349
* https://developer.apple.com/documentation/os/os_unfair_lock
4450
*
4551
* It deprecates OSSpinLock:
4652
* https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/spinlock.3.html
4753
*
48-
* The #defined BSG_DYLD_CACHE_LOCK/UNLOCK avoid spurious warnings on later OSs.
54+
* The imported headers have specific version info: <os/lock.h> and <libkern/OSAtomic.h>
4955
*/
5056

51-
#if defined(__IPHONE_10_0) || defined(__MAC_10_12) || defined(__TVOS_10_0) || defined(__WATCHOS_3_0)
52-
#pragma clang diagnostic push
53-
#pragma clang diagnostic ignored "-Wunguarded-availability"
54-
55-
#import <os/lock.h>
56-
static os_unfair_lock bsg_mach_binary_images_access_lock = OS_UNFAIR_LOCK_INIT;
57-
58-
#ifndef BSG_DYLD_CACHE_LOCK
59-
#define BSG_DYLD_CACHE_LOCK \
60-
_Pragma("clang diagnostic push") \
61-
_Pragma("clang diagnostic ignored \"-Wunguarded-availability\"") \
62-
os_unfair_lock_lock(&bsg_mach_binary_images_access_lock); \
63-
_Pragma("clang diagnostic pop")
64-
#endif
65-
66-
#ifndef BSG_DYLD_CACHE_UNLOCK
67-
#define BSG_DYLD_CACHE_UNLOCK \
68-
_Pragma("clang diagnostic push") \
69-
_Pragma("clang diagnostic ignored \"-Wunguarded-availability\"") \
70-
os_unfair_lock_unlock(&bsg_mach_binary_images_access_lock); \
71-
_Pragma("clang diagnostic pop")
72-
#endif
73-
74-
#pragma clang diagnostic pop
75-
#else
76-
#import <libkern/OSAtomic.h>
77-
static OSSpinLock bsg_mach_binary_images_access_lock = OS_SPINLOCK_INIT;
78-
79-
#ifndef BSG_DYLD_CACHE_LOCK
80-
#define BSG_DYLD_CACHE_LOCK OSSpinLockLock(&bsg_mach_binary_images_access_lock);
81-
#endif
82-
83-
#ifndef BSG_DYLD_CACHE_UNLOCK
84-
#define BSG_DYLD_CACHE_UNLOCK OSSpinLockUnlock(&bsg_mach_binary_images_access_lock);
85-
#endif
86-
#endif
57+
void bsg_spin_lock(void);
58+
void bsg_spin_unlock(void);
59+
void bsg_unfair_lock(void);
60+
void bsg_unfair_unlock(void);
61+
void bsg_dyld_cache_lock(void);
62+
void bsg_dyld_cache_unlock(void);
8763

8864
// MARK: - Replicate the DYLD API
8965

@@ -126,4 +102,9 @@ void bsg_mach_binary_image_removed(const struct mach_header *mh, intptr_t slide)
126102
*/
127103
BSG_Mach_Binary_Images *bsg_initialise_mach_binary_headers(uint32_t initialSize);
128104

105+
/**
106+
* Determines whether the OS supports unfair locks or not.
107+
*/
108+
void bsg_check_unfair_lock_support(void);
109+
129110
#endif /* BSG_KSMachHeaders_h */

cocoa/vendor/bugsnag-cocoa/Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.m

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,88 @@
1212
#import "BSG_KSDynamicLinker.h"
1313
#import "BSG_KSMachHeaders.h"
1414

15+
// MARK: - Locking
16+
17+
// Pragma's hide unavoidable (and expected) deprecation/unavailable warnings
18+
_Pragma("clang diagnostic push")
19+
_Pragma("clang diagnostic ignored \"-Wunguarded-availability\"")
20+
static os_unfair_lock bsg_mach_binary_images_access_lock_unfair = OS_UNFAIR_LOCK_INIT;
21+
_Pragma("clang diagnostic pop")
22+
23+
_Pragma("clang diagnostic push")
24+
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
25+
static OSSpinLock bsg_mach_binary_images_access_lock_spin = OS_SPINLOCK_INIT;
26+
_Pragma("clang diagnostic pop")
27+
28+
static BOOL bsg_unfair_lock_supported;
29+
30+
// Lock helpers. These use bulky Pragmas to hide warnings so are in their own functions for clarity.
31+
32+
void bsg_spin_lock() {
33+
_Pragma("clang diagnostic push")
34+
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
35+
OSSpinLockLock(&bsg_mach_binary_images_access_lock_spin);
36+
_Pragma("clang diagnostic pop")
37+
}
38+
39+
void bsg_spin_unlock() {
40+
_Pragma("clang diagnostic push")
41+
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
42+
OSSpinLockUnlock(&bsg_mach_binary_images_access_lock_spin);
43+
_Pragma("clang diagnostic pop")
44+
}
45+
46+
void bsg_unfair_lock() {
47+
_Pragma("clang diagnostic push")
48+
_Pragma("clang diagnostic ignored \"-Wunguarded-availability\"")
49+
os_unfair_lock_lock(&bsg_mach_binary_images_access_lock_unfair);
50+
_Pragma("clang diagnostic pop")
51+
}
52+
53+
void bsg_unfair_unlock() {
54+
_Pragma("clang diagnostic push")
55+
_Pragma("clang diagnostic ignored \"-Wunguarded-availability\"")
56+
os_unfair_lock_unlock(&bsg_mach_binary_images_access_lock_unfair);
57+
_Pragma("clang diagnostic pop")
58+
}
59+
60+
// Lock and unlock sections of code
61+
62+
void bsg_dyld_cache_lock() {
63+
if (bsg_unfair_lock_supported) {
64+
bsg_unfair_lock();
65+
} else {
66+
bsg_spin_lock();
67+
}
68+
}
69+
70+
void bsg_dyld_cache_unlock() {
71+
if (bsg_unfair_lock_supported) {
72+
bsg_unfair_unlock();
73+
} else {
74+
bsg_spin_unlock();
75+
}
76+
}
77+
78+
BOOL BSGIsUnfairLockSupported(NSProcessInfo *processInfo) {
79+
NSOperatingSystemVersion minSdk = {0,0,0};
80+
#if TARGET_OS_IOS
81+
minSdk.majorVersion = 10;
82+
#elif TARGET_OS_OSX
83+
minSdk.majorVersion = 10;
84+
minSdk.minorVersion = 12;
85+
#elif TARGET_OS_TV
86+
minSdk.majorVersion = 10;
87+
#elif TARGET_OS_WATCH
88+
minSdk.majorVersion = 3;
89+
#endif
90+
return [processInfo isOperatingSystemAtLeastVersion:minSdk];
91+
}
92+
93+
void bsg_check_unfair_lock_support() {
94+
bsg_unfair_lock_supported = BSGIsUnfairLockSupported([NSProcessInfo processInfo]);
95+
}
96+
1597
// MARK: - Replicate the DYLD API
1698

1799
uint32_t bsg_dyld_image_count(void) {
@@ -53,7 +135,7 @@ intptr_t bsg_dyld_get_image_vmaddr_slide(uint32_t imageIndex) {
53135
*/
54136
void bsg_add_mach_binary_image(BSG_Mach_Binary_Image_Info element) {
55137

56-
BSG_DYLD_CACHE_LOCK
138+
bsg_dyld_cache_lock();
57139

58140
// Expand array if necessary. We're slightly paranoid here. An OOM is likely to be indicative of bigger problems
59141
// but we should still do *our* best not to crash the app.
@@ -69,15 +151,15 @@ void bsg_add_mach_binary_image(BSG_Mach_Binary_Image_Info element) {
69151
}
70152
else {
71153
// Exit early, don't expand the array, don't store the header info and unlock
72-
BSG_DYLD_CACHE_UNLOCK
154+
bsg_dyld_cache_unlock();
73155
return;
74156
}
75157
}
76158

77159
// Store the value, increment the number of used elements
78160
bsg_mach_binary_images.contents[bsg_mach_binary_images.used++] = element;
79161

80-
BSG_DYLD_CACHE_UNLOCK
162+
bsg_dyld_cache_unlock();
81163
}
82164

83165
/**
@@ -87,7 +169,7 @@ void bsg_add_mach_binary_image(BSG_Mach_Binary_Image_Info element) {
87169
*/
88170
void bsg_remove_mach_binary_image(uint64_t imageVmAddr) {
89171

90-
BSG_DYLD_CACHE_LOCK
172+
bsg_dyld_cache_lock();
91173

92174
for (uint32_t i=0; i<bsg_mach_binary_images.used; i++) {
93175
BSG_Mach_Binary_Image_Info item = bsg_mach_binary_images.contents[i];
@@ -104,9 +186,16 @@ void bsg_remove_mach_binary_image(uint64_t imageVmAddr) {
104186
}
105187
}
106188

107-
BSG_DYLD_CACHE_UNLOCK
189+
bsg_dyld_cache_unlock();
108190
}
109191

192+
/**
193+
* Create an empty array with initial capacity to hold Mach header info.
194+
*
195+
* @param initialSize The initial array capacity
196+
*
197+
* @returns A struct for holding Mach binary image info
198+
*/
110199
BSG_Mach_Binary_Images *bsg_initialise_mach_binary_headers(uint32_t initialSize) {
111200
bsg_mach_binary_images.contents = (BSG_Mach_Binary_Image_Info *)malloc(initialSize * sizeof(BSG_Mach_Binary_Image_Info));
112201
bsg_mach_binary_images.used = 0;

cocoa/vendor/bugsnag-cocoa/iOS/Bugsnag.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"homepage": "https://www.bugsnag.com/platforms/react-native-error-reporting/",
44
"repository": "https://github.com/bugsnag/bugsnag-react-native.git",
55
"bugs": "https://github.com/bugsnag/bugsnag-react-native/issues",
6-
"version": "2.23.8",
6+
"version": "2.23.9",
77
"license": "MIT",
88
"main": "index.js",
99
"types": "index.d.ts",

0 commit comments

Comments
 (0)