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

Commit 8e920e6

Browse files
authored
Merge pull request #459 from bugsnag/release-2.23.8
Release v2.23.8
2 parents bc9564d + a467365 commit 8e920e6

16 files changed

Lines changed: 527 additions & 262 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
Changelog
22
=========
33

4-
## 2.23.8 (TBC)
4+
## 2.23.8 (2020-05-20)
5+
6+
## Bug fixes
57

68
* Fix missing comma in podspec headers list
79
[#456](https://github.com/bugsnag/bugsnag-react-native/pull/456)
810

11+
* (iOS) Fix an issue where an app could deadlock during a crash if unfavorable
12+
timing caused DYLD lock contention.
13+
[#580](https://github.com/bugsnag/bugsnag-cocoa/pull/580)
14+
915
## 2.23.7 (2020-04-07)
1016

1117
### Bug fixes
@@ -47,14 +53,14 @@ Changelog
4753
* `BugsnagConfiguration.autoCaptureSessions` is now named
4854
`BugsnagConfiguration.autoDetectSessions`
4955

50-
5156
## 2.23.5 (2020-01-13)
5257

5358
### Bug fixes
5459

5560
* (iOS) Fix a packaging issue introduced in 2.23.3 which prevented apps using
5661
React Native 0.59 and below from building successfully
5762
[#441](https://github.com/bugsnag/bugsnag-react-native/pull/441)
63+
5864
## 2.23.4 (2020-01-06)
5965

6066
### 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.7-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
2+
[![Documentation](https://img.shields.io/badge/documentation-2.23.8-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.7'
26+
versionName '2.23.8'
2727
consumerProguardFiles 'proguard-rules.pro'
2828
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2929
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ - (NSMutableDictionary *)generateCacheInfoWithConfig:(BugsnagConfiguration *)con
243243
app[@"releaseStage"] = config.releaseStage;
244244
app[@"version"] = systemInfo[@BSG_KSSystemField_BundleShortVersion] ?: @"";
245245
app[@"bundleVersion"] = systemInfo[@BSG_KSSystemField_BundleVersion] ?: @"";
246+
// 'codeBundleId' only (optionally) exists for React Native clients and defaults otherwise to nil
247+
app[@"codeBundleId"] = [config codeBundleId];
246248
#if BSGOOMAvailable
247249
UIApplicationState state = [BSG_KSSystemInfo currentAppState];
248250
app[@"inForeground"] = @([BSG_KSSystemInfo isInForeground:state]);
@@ -262,8 +264,12 @@ - (NSMutableDictionary *)generateCacheInfoWithConfig:(BugsnagConfiguration *)con
262264
// device[@"lowMemory"] is initially unset
263265
device[@"osBuild"] = systemInfo[@BSG_KSSystemField_OSVersion];
264266
device[@"osVersion"] = systemInfo[@BSG_KSSystemField_SystemVersion];
267+
device[@"osName"] = systemInfo[@BSG_KSSystemField_SystemName];
268+
// Translated from 'iDeviceMaj,Min' into human-readable "iPhone X" description on the server
265269
device[@"model"] = systemInfo[@BSG_KSSystemField_Machine];
270+
device[@"modelNumber"] = systemInfo[@ BSG_KSSystemField_Model];
266271
device[@"wordSize"] = @(PLATFORM_WORD_SIZE);
272+
device[@"locale"] = [[NSLocale currentLocale] localeIdentifier];
267273
#if TARGET_OS_SIMULATOR
268274
device[@"simulator"] = @YES;
269275
#else

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

Lines changed: 2 additions & 2 deletions
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.0";
50+
NSString *const NOTIFIER_VERSION = @"5.23.2";
5151
NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa";
5252
NSString *const BSTabCrash = @"crash";
5353
NSString *const BSAttributeDepth = @"depth";
@@ -471,7 +471,7 @@ - (void)watchLifecycleEvents:(NSNotificationCenter *)center {
471471

472472
#if TARGET_OS_TV || TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
473473
foregroundName = UIApplicationWillEnterForegroundNotification;
474-
backgroundName = UIApplicationWillEnterForegroundNotification;
474+
backgroundName = UIApplicationDidEnterBackgroundNotification;
475475
#elif TARGET_OS_MAC
476476
foregroundName = NSApplicationWillBecomeActiveNotification;
477477
backgroundName = NSApplicationDidFinishLaunchingNotification;

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
// THE SOFTWARE.
2525
//
2626

27+
#import <mach-o/dyld.h>
2728
#import "BSG_KSCrashAdvanced.h"
2829

2930
#import "BSG_KSCrashC.h"
3031
#import "BSG_KSCrashCallCompletion.h"
3132
#import "BSG_KSJSONCodecObjC.h"
3233
#import "BSG_KSSingleton.h"
3334
#import "BSG_KSSystemCapabilities.h"
35+
#import "BSG_KSMachHeaders.h"
3436
#import "NSError+BSG_SimpleConstructor.h"
3537

3638
//#define BSG_KSLogger_LocalLevel TRACE
@@ -49,6 +51,10 @@
4951
#define BSG_KSCRASH_DefaultReportFilesDirectory @"KSCrashReports"
5052
#endif
5153

54+
#ifndef BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE
55+
#define BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE 400
56+
#endif
57+
5258
// ============================================================================
5359
#pragma mark - Constants -
5460
// ============================================================================
@@ -219,13 +225,16 @@ - (NSString *)stateFilePath {
219225
}
220226

221227
- (BOOL)install {
228+
// Maintain a cache of info about dynamically loaded binary images
229+
[self listenForLoadedBinaries];
230+
222231
_handlingCrashTypes = bsg_kscrash_install(
223232
[self.crashReportPath UTF8String], [self.recrashReportPath UTF8String],
224233
[self.stateFilePath UTF8String], [self.nextCrashID UTF8String]);
225234
if (self.handlingCrashTypes == 0) {
226235
return false;
227236
}
228-
237+
229238
#if BSG_KSCRASH_HAS_UIKIT
230239
NSNotificationCenter *nCenter = [NSNotificationCenter defaultCenter];
231240
[nCenter addObserver:self
@@ -253,6 +262,21 @@ - (BOOL)install {
253262
return true;
254263
}
255264

265+
/**
266+
* Set up listeners for un/loaded frameworks. Maintaining our own list of framework Mach
267+
* headers means that we avoid potential deadlock situations where we try and suspend
268+
* lock-holding threads prior to loading mach headers as part of our normal event handling
269+
* behaviour.
270+
*/
271+
- (void)listenForLoadedBinaries {
272+
bsg_initialise_mach_binary_headers(BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE);
273+
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.
276+
_dyld_register_func_for_remove_image(&bsg_mach_binary_image_removed);
277+
_dyld_register_func_for_add_image(&bsg_mach_binary_image_added);
278+
}
279+
256280
- (void)sendAllReportsWithCompletion:
257281
(BSG_KSCrashReportFilterCompletion)onCompletion {
258282
[self.crashReportStore pruneFilesLeaving:self.maxStoredReports];

cocoa/vendor/bugsnag-cocoa/Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c

Lines changed: 18 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "BSG_KSObjC.h"
3737
#include "BSG_KSSignalInfo.h"
3838
#include "BSG_KSString.h"
39+
#include "BSG_KSMachHeaders.h"
3940

4041
//#define BSG_kSLogger_LocalLevel TRACE
4142
#include "BSG_KSLogger.h"
@@ -1084,70 +1085,23 @@ int bsg_kscrw_i_threadIndex(const thread_t thread) {
10841085
*
10851086
* @param key The object key, if needed.
10861087
*
1087-
* @param index Which image to write about.
1088+
* @param index Cached info about the binary image.
10881089
*/
10891090
void bsg_kscrw_i_writeBinaryImage(const BSG_KSCrashReportWriter *const writer,
1090-
const char *const key, const uint32_t index) {
1091-
const struct mach_header *header = _dyld_get_image_header(index);
1092-
if (header == NULL) {
1093-
return;
1094-
}
1095-
1096-
uintptr_t cmdPtr = bsg_ksdlfirstCmdAfterHeader(header);
1097-
if (cmdPtr == 0) {
1098-
return;
1099-
}
1100-
1101-
// Look for the TEXT segment to get the image size.
1102-
// Also look for a UUID command.
1103-
uint64_t imageSize = 0;
1104-
uint64_t imageVmAddr = 0;
1105-
uint8_t *uuid = NULL;
1106-
1107-
for (uint32_t iCmd = 0; iCmd < header->ncmds; iCmd++) {
1108-
struct load_command *loadCmd = (struct load_command *)cmdPtr;
1109-
switch (loadCmd->cmd) {
1110-
case LC_SEGMENT: {
1111-
struct segment_command *segCmd = (struct segment_command *)cmdPtr;
1112-
if (strcmp(segCmd->segname, SEG_TEXT) == 0) {
1113-
imageSize = segCmd->vmsize;
1114-
imageVmAddr = segCmd->vmaddr;
1115-
}
1116-
break;
1117-
}
1118-
case LC_SEGMENT_64: {
1119-
struct segment_command_64 *segCmd =
1120-
(struct segment_command_64 *)cmdPtr;
1121-
if (strcmp(segCmd->segname, SEG_TEXT) == 0) {
1122-
imageSize = segCmd->vmsize;
1123-
imageVmAddr = segCmd->vmaddr;
1124-
}
1125-
break;
1126-
}
1127-
case LC_UUID: {
1128-
struct uuid_command *uuidCmd = (struct uuid_command *)cmdPtr;
1129-
uuid = uuidCmd->uuid;
1130-
break;
1131-
}
1132-
}
1133-
cmdPtr += loadCmd->cmdsize;
1134-
}
1135-
1091+
const char *const key,
1092+
const uint32_t index)
1093+
{
1094+
BSG_Mach_Binary_Image_Info info = *bsg_dyld_get_image_info(index);
1095+
11361096
writer->beginObject(writer, key);
11371097
{
1138-
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageAddress,
1139-
(uintptr_t)header);
1140-
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageVmAddress,
1141-
imageVmAddr);
1142-
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageSize,
1143-
imageSize);
1144-
writer->addStringElement(writer, BSG_KSCrashField_Name,
1145-
_dyld_get_image_name(index));
1146-
writer->addUUIDElement(writer, BSG_KSCrashField_UUID, uuid);
1147-
writer->addIntegerElement(writer, BSG_KSCrashField_CPUType,
1148-
header->cputype);
1149-
writer->addIntegerElement(writer, BSG_KSCrashField_CPUSubType,
1150-
header->cpusubtype);
1098+
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageAddress, (uintptr_t)info.header);
1099+
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageVmAddress, info.imageVmAddr);
1100+
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageSize, info.imageSize);
1101+
writer->addStringElement(writer, BSG_KSCrashField_Name, info.name);
1102+
writer->addUUIDElement(writer, BSG_KSCrashField_UUID, info.uuid);
1103+
writer->addIntegerElement(writer, BSG_KSCrashField_CPUType, info.header->cputype);
1104+
writer->addIntegerElement(writer, BSG_KSCrashField_CPUSubType, info.header->cpusubtype);
11511105
}
11521106
writer->endContainer(writer);
11531107
}
@@ -1159,12 +1113,14 @@ void bsg_kscrw_i_writeBinaryImage(const BSG_KSCrashReportWriter *const writer,
11591113
* @param key The object key, if needed.
11601114
*/
11611115
void bsg_kscrw_i_writeBinaryImages(const BSG_KSCrashReportWriter *const writer,
1162-
const char *const key) {
1163-
const uint32_t imageCount = _dyld_image_count();
1116+
const char *const key)
1117+
{
1118+
const uint32_t imageCount = bsg_dyld_image_count();
11641119

11651120
writer->beginArray(writer, key);
11661121
{
11671122
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
1123+
// Threads are suspended at this point; no need to synchronise/lock
11681124
bsg_kscrw_i_writeBinaryImage(writer, NULL, iImg);
11691125
}
11701126
}
@@ -1658,9 +1614,6 @@ void bsg_kscrashreport_writeStandardReport(
16581614

16591615
bsg_ksjsonendEncode(bsg_getJsonContext(writer));
16601616

1661-
if (!bsg_ksfuflushWriteBuffer(fd)) {
1662-
BSG_KSLOG_ERROR("Failed to flush write buffer");
1663-
}
16641617
close(fd);
16651618
}
16661619

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ bool bsg_kscrashstate_i_saveState(const BSG_KSCrash_State *const state,
263263
goto done;
264264
}
265265
result = bsg_ksjsonendEncode(&JSONContext);
266-
if (!bsg_ksfuflushWriteBuffer(fd)) {
267-
BSG_KSLOG_ERROR(@"Failed to flush write buffer");
268-
}
269266

270267
done:
271268
close(fd);

cocoa/vendor/bugsnag-cocoa/Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSDynamicLinker.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@
2626

2727
#include "BSG_KSDynamicLinker.h"
2828
#include "BSG_KSArchSpecific.h"
29+
#include "BSG_KSMachHeaders.h"
2930

3031
#include <limits.h>
3132
#include <mach-o/nlist.h>
3233
#include <string.h>
3334

3435
uint32_t bsg_ksdlimageNamed(const char *const imageName, bool exactMatch) {
3536
if (imageName != NULL) {
36-
const uint32_t imageCount = _dyld_image_count();
37-
37+
const uint32_t imageCount = bsg_dyld_image_count();
38+
3839
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
39-
const char *name = _dyld_get_image_name(iImg);
40+
const char *name = bsg_dyld_get_image_name(iImg);
4041
if (name == NULL) {
4142
continue; // name is null if the index is out of range per dyld(3)
4243
} else if (exactMatch) {
@@ -57,7 +58,7 @@ const uint8_t *bsg_ksdlimageUUID(const char *const imageName, bool exactMatch) {
5758
if (imageName != NULL) {
5859
const uint32_t iImg = bsg_ksdlimageNamed(imageName, exactMatch);
5960
if (iImg != UINT32_MAX) {
60-
const struct mach_header *header = _dyld_get_image_header(iImg);
61+
const struct mach_header *header = bsg_dyld_get_image_header(iImg);
6162
if (header != NULL) {
6263
uintptr_t cmdPtr = bsg_ksdlfirstCmdAfterHeader(header);
6364
if (cmdPtr != 0) {
@@ -96,15 +97,15 @@ uintptr_t bsg_ksdlfirstCmdAfterHeader(const struct mach_header *const header) {
9697
}
9798

9899
uint32_t bsg_ksdlimageIndexContainingAddress(const uintptr_t address) {
99-
const uint32_t imageCount = _dyld_image_count();
100+
const uint32_t imageCount = bsg_dyld_image_count();
100101
const struct mach_header *header = 0;
101102

102103
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
103-
header = _dyld_get_image_header(iImg);
104+
header = bsg_dyld_get_image_header(iImg);
104105
if (header != NULL) {
105106
// Look for a segment command with this address within its range.
106107
uintptr_t addressWSlide =
107-
address - (uintptr_t)_dyld_get_image_vmaddr_slide(iImg);
108+
address - bsg_dyld_get_image_vmaddr_slide(iImg);
108109
uintptr_t cmdPtr = bsg_ksdlfirstCmdAfterHeader(header);
109110
if (cmdPtr == 0) {
110111
continue;
@@ -135,7 +136,7 @@ uint32_t bsg_ksdlimageIndexContainingAddress(const uintptr_t address) {
135136
}
136137

137138
uintptr_t bsg_ksdlsegmentBaseOfImageIndex(const uint32_t idx) {
138-
const struct mach_header *header = _dyld_get_image_header(idx);
139+
const struct mach_header *header = bsg_dyld_get_image_header(idx);
139140
if (header == NULL) {
140141
return 0;
141142
}
@@ -176,20 +177,20 @@ bool bsg_ksdldladdr(const uintptr_t address, Dl_info *const info) {
176177
if (idx == UINT_MAX) {
177178
return false;
178179
}
179-
const struct mach_header *header = _dyld_get_image_header(idx);
180+
const struct mach_header *header = bsg_dyld_get_image_header(idx);
180181
if (header == NULL) {
181182
return false;
182183
}
183184
const uintptr_t imageVMAddrSlide =
184-
(uintptr_t)_dyld_get_image_vmaddr_slide(idx);
185+
bsg_dyld_get_image_vmaddr_slide(idx);
185186
const uintptr_t addressWithSlide = address - imageVMAddrSlide;
186187
const uintptr_t segmentBase =
187188
bsg_ksdlsegmentBaseOfImageIndex(idx) + imageVMAddrSlide;
188189
if (segmentBase == 0) {
189190
return false;
190191
}
191192

192-
info->dli_fname = _dyld_get_image_name(idx);
193+
info->dli_fname = bsg_dyld_get_image_name(idx);
193194
info->dli_fbase = (void *)header;
194195

195196
// Find symbol tables and get whichever symbol is closest to the address.
@@ -244,12 +245,12 @@ bool bsg_ksdldladdr(const uintptr_t address, Dl_info *const info) {
244245

245246
const void *bsg_ksdlgetSymbolAddrInImage(uint32_t imageIdx,
246247
const char *symbolName) {
247-
const struct mach_header *header = _dyld_get_image_header(imageIdx);
248+
const struct mach_header *header = bsg_dyld_get_image_header(imageIdx);
248249
if (header == NULL) {
249250
return NULL;
250251
}
251252
const uintptr_t imageVMAddrSlide =
252-
(uintptr_t)_dyld_get_image_vmaddr_slide(imageIdx);
253+
bsg_dyld_get_image_vmaddr_slide(imageIdx);
253254
const uintptr_t segmentBase =
254255
bsg_ksdlsegmentBaseOfImageIndex(imageIdx) + imageVMAddrSlide;
255256
if (segmentBase == 0) {
@@ -290,7 +291,7 @@ const void *bsg_ksdlgetSymbolAddrInImage(uint32_t imageIdx,
290291
}
291292

292293
const void *bsg_ksdlgetSymbolAddrInAnyImage(const char *symbolName) {
293-
const uint32_t imageCount = _dyld_image_count();
294+
const uint32_t imageCount = bsg_dyld_image_count();
294295

295296
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
296297
const void *symbolAddr = bsg_ksdlgetSymbolAddrInImage(iImg, symbolName);

0 commit comments

Comments
 (0)