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

Commit

Permalink
Merge pull request #459 from bugsnag/release-2.23.8
Browse files Browse the repository at this point in the history
Release v2.23.8
  • Loading branch information
tomlongridge authored May 20, 2020
2 parents bc9564d + a467365 commit 8e920e6
Show file tree
Hide file tree
Showing 16 changed files with 527 additions and 262 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
Changelog
=========

## 2.23.8 (TBC)
## 2.23.8 (2020-05-20)

## Bug fixes

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

* (iOS) Fix an issue where an app could deadlock during a crash if unfavorable
timing caused DYLD lock contention.
[#580](https://github.com/bugsnag/bugsnag-cocoa/pull/580)

## 2.23.7 (2020-04-07)

### Bug fixes
Expand Down Expand Up @@ -47,14 +53,14 @@ Changelog
* `BugsnagConfiguration.autoCaptureSessions` is now named
`BugsnagConfiguration.autoDetectSessions`


## 2.23.5 (2020-01-13)

### Bug fixes

* (iOS) Fix a packaging issue introduced in 2.23.3 which prevented apps using
React Native 0.59 and below from building successfully
[#441](https://github.com/bugsnag/bugsnag-react-native/pull/441)

## 2.23.4 (2020-01-06)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Bugsnag error monitoring & exception reporter for React Native
[![Documentation](https://img.shields.io/badge/documentation-2.23.7-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
[![Documentation](https://img.shields.io/badge/documentation-2.23.8-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)

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.

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 4
versionName '2.23.7'
versionName '2.23.8'
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
6 changes: 6 additions & 0 deletions cocoa/vendor/bugsnag-cocoa/Source/BSGOutOfMemoryWatchdog.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ - (NSMutableDictionary *)generateCacheInfoWithConfig:(BugsnagConfiguration *)con
app[@"releaseStage"] = config.releaseStage;
app[@"version"] = systemInfo[@BSG_KSSystemField_BundleShortVersion] ?: @"";
app[@"bundleVersion"] = systemInfo[@BSG_KSSystemField_BundleVersion] ?: @"";
// 'codeBundleId' only (optionally) exists for React Native clients and defaults otherwise to nil
app[@"codeBundleId"] = [config codeBundleId];
#if BSGOOMAvailable
UIApplicationState state = [BSG_KSSystemInfo currentAppState];
app[@"inForeground"] = @([BSG_KSSystemInfo isInForeground:state]);
Expand All @@ -262,8 +264,12 @@ - (NSMutableDictionary *)generateCacheInfoWithConfig:(BugsnagConfiguration *)con
// device[@"lowMemory"] is initially unset
device[@"osBuild"] = systemInfo[@BSG_KSSystemField_OSVersion];
device[@"osVersion"] = systemInfo[@BSG_KSSystemField_SystemVersion];
device[@"osName"] = systemInfo[@BSG_KSSystemField_SystemName];
// Translated from 'iDeviceMaj,Min' into human-readable "iPhone X" description on the server
device[@"model"] = systemInfo[@BSG_KSSystemField_Machine];
device[@"modelNumber"] = systemInfo[@ BSG_KSSystemField_Model];
device[@"wordSize"] = @(PLATFORM_WORD_SIZE);
device[@"locale"] = [[NSLocale currentLocale] localeIdentifier];
#if TARGET_OS_SIMULATOR
device[@"simulator"] = @YES;
#else
Expand Down
4 changes: 2 additions & 2 deletions cocoa/vendor/bugsnag-cocoa/Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#import <AppKit/AppKit.h>
#endif

NSString *const NOTIFIER_VERSION = @"5.23.0";
NSString *const NOTIFIER_VERSION = @"5.23.2";
NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa";
NSString *const BSTabCrash = @"crash";
NSString *const BSAttributeDepth = @"depth";
Expand Down Expand Up @@ -471,7 +471,7 @@ - (void)watchLifecycleEvents:(NSNotificationCenter *)center {

#if TARGET_OS_TV || TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
foregroundName = UIApplicationWillEnterForegroundNotification;
backgroundName = UIApplicationWillEnterForegroundNotification;
backgroundName = UIApplicationDidEnterBackgroundNotification;
#elif TARGET_OS_MAC
foregroundName = NSApplicationWillBecomeActiveNotification;
backgroundName = NSApplicationDidFinishLaunchingNotification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
// THE SOFTWARE.
//

#import <mach-o/dyld.h>
#import "BSG_KSCrashAdvanced.h"

#import "BSG_KSCrashC.h"
#import "BSG_KSCrashCallCompletion.h"
#import "BSG_KSJSONCodecObjC.h"
#import "BSG_KSSingleton.h"
#import "BSG_KSSystemCapabilities.h"
#import "BSG_KSMachHeaders.h"
#import "NSError+BSG_SimpleConstructor.h"

//#define BSG_KSLogger_LocalLevel TRACE
Expand All @@ -49,6 +51,10 @@
#define BSG_KSCRASH_DefaultReportFilesDirectory @"KSCrashReports"
#endif

#ifndef BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE
#define BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE 400
#endif

// ============================================================================
#pragma mark - Constants -
// ============================================================================
Expand Down Expand Up @@ -219,13 +225,16 @@ - (NSString *)stateFilePath {
}

- (BOOL)install {
// Maintain a cache of info about dynamically loaded binary images
[self listenForLoadedBinaries];

_handlingCrashTypes = bsg_kscrash_install(
[self.crashReportPath UTF8String], [self.recrashReportPath UTF8String],
[self.stateFilePath UTF8String], [self.nextCrashID UTF8String]);
if (self.handlingCrashTypes == 0) {
return false;
}

#if BSG_KSCRASH_HAS_UIKIT
NSNotificationCenter *nCenter = [NSNotificationCenter defaultCenter];
[nCenter addObserver:self
Expand Down Expand Up @@ -253,6 +262,21 @@ - (BOOL)install {
return true;
}

/**
* Set up listeners for un/loaded frameworks. Maintaining our own list of framework Mach
* headers means that we avoid potential deadlock situations where we try and suspend
* lock-holding threads prior to loading mach headers as part of our normal event handling
* behaviour.
*/
- (void)listenForLoadedBinaries {
bsg_initialise_mach_binary_headers(BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE);

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

- (void)sendAllReportsWithCompletion:
(BSG_KSCrashReportFilterCompletion)onCompletion {
[self.crashReportStore pruneFilesLeaving:self.maxStoredReports];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "BSG_KSObjC.h"
#include "BSG_KSSignalInfo.h"
#include "BSG_KSString.h"
#include "BSG_KSMachHeaders.h"

//#define BSG_kSLogger_LocalLevel TRACE
#include "BSG_KSLogger.h"
Expand Down Expand Up @@ -1084,70 +1085,23 @@ int bsg_kscrw_i_threadIndex(const thread_t thread) {
*
* @param key The object key, if needed.
*
* @param index Which image to write about.
* @param index Cached info about the binary image.
*/
void bsg_kscrw_i_writeBinaryImage(const BSG_KSCrashReportWriter *const writer,
const char *const key, const uint32_t index) {
const struct mach_header *header = _dyld_get_image_header(index);
if (header == NULL) {
return;
}

uintptr_t cmdPtr = bsg_ksdlfirstCmdAfterHeader(header);
if (cmdPtr == 0) {
return;
}

// Look for the TEXT segment to get the image size.
// Also look for a UUID command.
uint64_t imageSize = 0;
uint64_t imageVmAddr = 0;
uint8_t *uuid = NULL;

for (uint32_t iCmd = 0; iCmd < header->ncmds; iCmd++) {
struct load_command *loadCmd = (struct load_command *)cmdPtr;
switch (loadCmd->cmd) {
case LC_SEGMENT: {
struct segment_command *segCmd = (struct segment_command *)cmdPtr;
if (strcmp(segCmd->segname, SEG_TEXT) == 0) {
imageSize = segCmd->vmsize;
imageVmAddr = segCmd->vmaddr;
}
break;
}
case LC_SEGMENT_64: {
struct segment_command_64 *segCmd =
(struct segment_command_64 *)cmdPtr;
if (strcmp(segCmd->segname, SEG_TEXT) == 0) {
imageSize = segCmd->vmsize;
imageVmAddr = segCmd->vmaddr;
}
break;
}
case LC_UUID: {
struct uuid_command *uuidCmd = (struct uuid_command *)cmdPtr;
uuid = uuidCmd->uuid;
break;
}
}
cmdPtr += loadCmd->cmdsize;
}

const char *const key,
const uint32_t index)
{
BSG_Mach_Binary_Image_Info info = *bsg_dyld_get_image_info(index);

writer->beginObject(writer, key);
{
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageAddress,
(uintptr_t)header);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageVmAddress,
imageVmAddr);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageSize,
imageSize);
writer->addStringElement(writer, BSG_KSCrashField_Name,
_dyld_get_image_name(index));
writer->addUUIDElement(writer, BSG_KSCrashField_UUID, uuid);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUType,
header->cputype);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUSubType,
header->cpusubtype);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageAddress, (uintptr_t)info.header);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageVmAddress, info.imageVmAddr);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageSize, info.imageSize);
writer->addStringElement(writer, BSG_KSCrashField_Name, info.name);
writer->addUUIDElement(writer, BSG_KSCrashField_UUID, info.uuid);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUType, info.header->cputype);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUSubType, info.header->cpusubtype);
}
writer->endContainer(writer);
}
Expand All @@ -1159,12 +1113,14 @@ void bsg_kscrw_i_writeBinaryImage(const BSG_KSCrashReportWriter *const writer,
* @param key The object key, if needed.
*/
void bsg_kscrw_i_writeBinaryImages(const BSG_KSCrashReportWriter *const writer,
const char *const key) {
const uint32_t imageCount = _dyld_image_count();
const char *const key)
{
const uint32_t imageCount = bsg_dyld_image_count();

writer->beginArray(writer, key);
{
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
// Threads are suspended at this point; no need to synchronise/lock
bsg_kscrw_i_writeBinaryImage(writer, NULL, iImg);
}
}
Expand Down Expand Up @@ -1658,9 +1614,6 @@ void bsg_kscrashreport_writeStandardReport(

bsg_ksjsonendEncode(bsg_getJsonContext(writer));

if (!bsg_ksfuflushWriteBuffer(fd)) {
BSG_KSLOG_ERROR("Failed to flush write buffer");
}
close(fd);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ bool bsg_kscrashstate_i_saveState(const BSG_KSCrash_State *const state,
goto done;
}
result = bsg_ksjsonendEncode(&JSONContext);
if (!bsg_ksfuflushWriteBuffer(fd)) {
BSG_KSLOG_ERROR(@"Failed to flush write buffer");
}

done:
close(fd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@

#include "BSG_KSDynamicLinker.h"
#include "BSG_KSArchSpecific.h"
#include "BSG_KSMachHeaders.h"

#include <limits.h>
#include <mach-o/nlist.h>
#include <string.h>

uint32_t bsg_ksdlimageNamed(const char *const imageName, bool exactMatch) {
if (imageName != NULL) {
const uint32_t imageCount = _dyld_image_count();

const uint32_t imageCount = bsg_dyld_image_count();
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
const char *name = _dyld_get_image_name(iImg);
const char *name = bsg_dyld_get_image_name(iImg);
if (name == NULL) {
continue; // name is null if the index is out of range per dyld(3)
} else if (exactMatch) {
Expand All @@ -57,7 +58,7 @@ const uint8_t *bsg_ksdlimageUUID(const char *const imageName, bool exactMatch) {
if (imageName != NULL) {
const uint32_t iImg = bsg_ksdlimageNamed(imageName, exactMatch);
if (iImg != UINT32_MAX) {
const struct mach_header *header = _dyld_get_image_header(iImg);
const struct mach_header *header = bsg_dyld_get_image_header(iImg);
if (header != NULL) {
uintptr_t cmdPtr = bsg_ksdlfirstCmdAfterHeader(header);
if (cmdPtr != 0) {
Expand Down Expand Up @@ -96,15 +97,15 @@ uintptr_t bsg_ksdlfirstCmdAfterHeader(const struct mach_header *const header) {
}

uint32_t bsg_ksdlimageIndexContainingAddress(const uintptr_t address) {
const uint32_t imageCount = _dyld_image_count();
const uint32_t imageCount = bsg_dyld_image_count();
const struct mach_header *header = 0;

for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
header = _dyld_get_image_header(iImg);
header = bsg_dyld_get_image_header(iImg);
if (header != NULL) {
// Look for a segment command with this address within its range.
uintptr_t addressWSlide =
address - (uintptr_t)_dyld_get_image_vmaddr_slide(iImg);
address - bsg_dyld_get_image_vmaddr_slide(iImg);
uintptr_t cmdPtr = bsg_ksdlfirstCmdAfterHeader(header);
if (cmdPtr == 0) {
continue;
Expand Down Expand Up @@ -135,7 +136,7 @@ uint32_t bsg_ksdlimageIndexContainingAddress(const uintptr_t address) {
}

uintptr_t bsg_ksdlsegmentBaseOfImageIndex(const uint32_t idx) {
const struct mach_header *header = _dyld_get_image_header(idx);
const struct mach_header *header = bsg_dyld_get_image_header(idx);
if (header == NULL) {
return 0;
}
Expand Down Expand Up @@ -176,20 +177,20 @@ bool bsg_ksdldladdr(const uintptr_t address, Dl_info *const info) {
if (idx == UINT_MAX) {
return false;
}
const struct mach_header *header = _dyld_get_image_header(idx);
const struct mach_header *header = bsg_dyld_get_image_header(idx);
if (header == NULL) {
return false;
}
const uintptr_t imageVMAddrSlide =
(uintptr_t)_dyld_get_image_vmaddr_slide(idx);
bsg_dyld_get_image_vmaddr_slide(idx);
const uintptr_t addressWithSlide = address - imageVMAddrSlide;
const uintptr_t segmentBase =
bsg_ksdlsegmentBaseOfImageIndex(idx) + imageVMAddrSlide;
if (segmentBase == 0) {
return false;
}

info->dli_fname = _dyld_get_image_name(idx);
info->dli_fname = bsg_dyld_get_image_name(idx);
info->dli_fbase = (void *)header;

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

const void *bsg_ksdlgetSymbolAddrInImage(uint32_t imageIdx,
const char *symbolName) {
const struct mach_header *header = _dyld_get_image_header(imageIdx);
const struct mach_header *header = bsg_dyld_get_image_header(imageIdx);
if (header == NULL) {
return NULL;
}
const uintptr_t imageVMAddrSlide =
(uintptr_t)_dyld_get_image_vmaddr_slide(imageIdx);
bsg_dyld_get_image_vmaddr_slide(imageIdx);
const uintptr_t segmentBase =
bsg_ksdlsegmentBaseOfImageIndex(imageIdx) + imageVMAddrSlide;
if (segmentBase == 0) {
Expand Down Expand Up @@ -290,7 +291,7 @@ const void *bsg_ksdlgetSymbolAddrInImage(uint32_t imageIdx,
}

const void *bsg_ksdlgetSymbolAddrInAnyImage(const char *symbolName) {
const uint32_t imageCount = _dyld_image_count();
const uint32_t imageCount = bsg_dyld_image_count();

for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
const void *symbolAddr = bsg_ksdlgetSymbolAddrInImage(iImg, symbolName);
Expand Down
Loading

0 comments on commit 8e920e6

Please sign in to comment.