Skip to content

Commit

Permalink
Merge pull request #1499 from bugsnag/release-v6.25.0
Browse files Browse the repository at this point in the history
Release v6.25.0
  • Loading branch information
kstenerud authored Oct 26, 2022
2 parents 6f3c487 + efa7e1e commit 056b1c1
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ author_url: "https://www.bugsnag.com"
author: "Bugsnag Inc"
clean: false # avoid deleting docs/.git
framework_root: "Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.24.0/Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.25.0/Bugsnag"
github_url: "https://github.com/bugsnag/bugsnag-cocoa"
hide_documentation_coverage: true
module: "Bugsnag"
module_version: "6.24.0"
module_version: "6.25.0"
objc: true
output: "docs"
readme: "README.md"
Expand Down
4 changes: 2 additions & 2 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "6.24.0",
"version": "6.25.0",
"summary": "The Bugsnag crash reporting framework for Apple platforms.",
"homepage": "https://bugsnag.com",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v6.24.0"
"tag": "v6.25.0"
},
"ios": {
"frameworks": [
Expand Down
11 changes: 11 additions & 0 deletions Bugsnag.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES // -Wimplicit-retai
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES // -Warc-repeated-use-of-weak -Wno-arc-maybe-repeated-use-of-weak
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES // -Warc-bridge-casts-disallowed-in-nonarc

// Static Analysis - Issues - Security

CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES

// Static Analysis - Issues - Unused Code

CLANG_TIDY_BUGPRONE_REDUNDANT_BRANCH_CONDITION = YES
CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES

// Warning flags that have no dedicated Xcode build settings

WARNING_CFLAGS = -Wcast-qual -Wconditional-uninitialized -Wcustom-atomic-properties -Wdirect-ivar-access -Wdocumentation-unknown-command -Wformat-nonliteral -Widiomatic-parentheses -Wimplicit-int-float-conversion -Wimport-preprocessor-directive-pedantic -Wincomplete-implementation -Wmissing-variable-declarations -Wno-unknown-warning-option -Wnonportable-include-path -Wnullable-to-nonnull-conversion -Woverriding-method-mismatch -Wpointer-sign -Wswitch-enum -Wundef -Wunused-macros
Expand Down
6 changes: 4 additions & 2 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer) {
// MARK: -

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagClient () <BSGBreadcrumbSink, BSGInternalErrorReporterDataSource>
@interface BugsnagClient () <BSGBreadcrumbSink>

@property (nonatomic) BSGNotificationBreadcrumbs *notificationBreadcrumbs;

Expand Down Expand Up @@ -246,7 +246,9 @@ - (void)start {
[self computeDidCrashLastLaunch];

if (self.configuration.telemetry & BSGTelemetryInternalErrors) {
BSGInternalErrorReporter.sharedInstance = [[BSGInternalErrorReporter alloc] initWithDataSource:self];
BSGInternalErrorReporter.sharedInstance =
[[BSGInternalErrorReporter alloc] initWithApiKey:self.configuration.apiKey
endpoint:(NSURL *_Nonnull)self.configuration.notifyURL];
} else {
bsg_log_debug(@"Internal error reporting was disabled in config");
}
Expand Down
18 changes: 1 addition & 17 deletions Bugsnag/Helpers/BSGInternalErrorReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@

#import "BSGDefines.h"

@class BugsnagAppWithState;
@class BugsnagConfiguration;
@class BugsnagDeviceWithState;
@class BugsnagEvent;
@class BugsnagNotifier;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -23,18 +19,6 @@ NSString *_Nullable BSGErrorDescription(NSError *_Nullable error);

// MARK: -

@protocol BSGInternalErrorReporterDataSource <NSObject>

@property (readonly, nonatomic) BugsnagConfiguration *configuration;

- (BugsnagAppWithState *)generateAppWithState:(NSDictionary *)systemInfo;

- (BugsnagDeviceWithState *)generateDeviceWithState:(NSDictionary *)systemInfo;

@end

// MARK: -

BSG_OBJC_DIRECT_MEMBERS
@interface BSGInternalErrorReporter : NSObject

Expand All @@ -43,7 +27,7 @@ BSG_OBJC_DIRECT_MEMBERS
/// Runs the block immediately if sharedInstance exists, otherwise runs the block once sharedInstance has been created.
+ (void)performBlock:(void (^)(BSGInternalErrorReporter *))block;

- (instancetype)initWithDataSource:(id<BSGInternalErrorReporterDataSource>)dataSource NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithApiKey:(NSString *)apiKey endpoint:(NSURL *)endpoint NS_DESIGNATED_INITIALIZER;

- (instancetype)init UNAVAILABLE_ATTRIBUTE;

Expand Down
67 changes: 34 additions & 33 deletions Bugsnag/Helpers/BSGInternalErrorReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
#import "BSGKeys.h"
#import "BSG_KSCrashReportFields.h"
#import "BSG_KSSysCtl.h"
#import "BSG_KSSystemInfo.h"
#import "BSG_RFC3339DateTool.h"
#import "BugsnagApiClient.h"
#import "BugsnagAppWithState+Private.h"
#import "BugsnagCollections.h"
#import "BugsnagConfiguration+Private.h"
#import "BugsnagDeviceWithState+Private.h"
#import "BugsnagError+Private.h"
#import "BugsnagEvent+Private.h"
#import "BugsnagHandledState.h"
Expand Down Expand Up @@ -50,13 +46,16 @@

static NSString * DeviceId(void);

static NSString * Sysctl(const char *name);


// MARK: -

BSG_OBJC_DIRECT_MEMBERS
@interface BSGInternalErrorReporter ()

@property (weak, nullable, nonatomic) id<BSGInternalErrorReporterDataSource> dataSource;
@property (nonatomic) NSString *apiKey;
@property (nonatomic) NSURL *endpoint;
@property (nonatomic) NSURLSession *session;

@end
Expand Down Expand Up @@ -88,9 +87,10 @@ + (void)performBlock:(void (^)(BSGInternalErrorReporter *))block {
}
}

- (instancetype)initWithDataSource:(id<BSGInternalErrorReporterDataSource>)dataSource {
- (instancetype)initWithApiKey:(NSString *)apiKey endpoint:(NSURL *)endpoint {
if ((self = [super init])) {
_dataSource = dataSource;
_apiKey = apiKey;
_endpoint = endpoint;
_session = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.ephemeralSessionConfiguration];
}
return self;
Expand Down Expand Up @@ -199,24 +199,30 @@ - (nullable BugsnagEvent *)eventWithError:(BugsnagError *)error
diagnostics:(nullable NSDictionary<NSString *, id> *)diagnostics
groupingHash:(nullable NSString *)groupingHash {

id<BSGInternalErrorReporterDataSource> dataSource = self.dataSource;
if (!dataSource) {
return nil;
}

BugsnagMetadata *metadata = [[BugsnagMetadata alloc] init];
if (diagnostics) {
[metadata addMetadata:(NSDictionary * _Nonnull)diagnostics toSection:BugsnagDiagnosticsKey];
}
[metadata addMetadata:dataSource.configuration.apiKey withKey:BSGKeyApiKey toSection:BugsnagDiagnosticsKey];
[metadata addMetadata:self.apiKey withKey:BSGKeyApiKey toSection:BugsnagDiagnosticsKey];

NSDictionary *systemVersion = [NSDictionary dictionaryWithContentsOfFile:
@"/System/Library/CoreServices/SystemVersion.plist"];

NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo];
BugsnagDeviceWithState *device = [BugsnagDeviceWithState new];
device.id = DeviceId();
device.manufacturer = @"Apple";
device.osName = systemVersion[@"ProductName"];
device.osVersion = systemVersion[@"ProductVersion"];

BugsnagDeviceWithState *device = [dataSource generateDeviceWithState:systemInfo];
device.id = DeviceId();
#if TARGET_OS_OSX || TARGET_OS_SIMULATOR || (defined(TARGET_OS_MACCATALYST) && TARGET_OS_MACCATALYST)
device.model = Sysctl("hw.model");
#else
device.model = Sysctl("hw.machine");
device.modelNumber = Sysctl("hw.model");
#endif

BugsnagEvent *event =
[[BugsnagEvent alloc] initWithApp:[dataSource generateAppWithState:systemInfo]
[[BugsnagEvent alloc] initWithApp:[BugsnagAppWithState new]
device:device
handledState:[BugsnagHandledState handledStateWithSeverityReason:HandledError]
user:[[BugsnagUser alloc] init]
Expand All @@ -235,20 +241,6 @@ - (nullable BugsnagEvent *)eventWithError:(BugsnagError *)error
// MARK: Delivery

- (NSURLRequest *)requestForEvent:(nonnull BugsnagEvent *)event error:(NSError * __autoreleasing *)errorPtr {
id<BSGInternalErrorReporterDataSource> dataSource = self.dataSource;
if (!dataSource) {
return nil;
}

NSURL *url = dataSource.configuration.notifyURL;
if (!url) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:@"BugsnagConfigurationErrorDomain" code:0
userInfo:@{NSLocalizedDescriptionKey: @"Missing notify URL"}];
}
return nil;
}

NSMutableDictionary *requestPayload = [NSMutableDictionary dictionary];
requestPayload[BSGKeyEvents] = @[[event toJsonWithRedactedKeys:nil]];
requestPayload[BSGKeyNotifier] = [[[BugsnagNotifier alloc] init] toDict];
Expand All @@ -266,7 +258,7 @@ - (NSURLRequest *)requestForEvent:(nonnull BugsnagEvent *)event error:(NSError *
headers[BugsnagHTTPHeaderNamePayloadVersion] = EventPayloadVersion;
headers[BugsnagHTTPHeaderNameSentAt] = [BSG_RFC3339DateTool stringFromDate:[NSDate date]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.endpoint];
request.allHTTPHeaderFields = headers;
request.HTTPBody = data;
request.HTTPMethod = @"POST";
Expand Down Expand Up @@ -303,7 +295,7 @@ - (void)sendEvent:(nonnull BugsnagEvent *)event {
CC_SHA1_Update(&ctx, uuid, sizeof(uuid));
#elif TARGET_OS_WATCH
uuid_t uuid = {0};
[[[NSClassFromString(@"WKInterfaceDevice") currentDevice] identifierForVendor] getUUIDBytes:uuid];
[[[WKInterfaceDevice currentDevice] identifierForVendor] getUUIDBytes:uuid];
CC_SHA1_Update(&ctx, uuid, sizeof(uuid));
#else
#error Unsupported target platform
Expand All @@ -325,3 +317,12 @@ - (void)sendEvent:(nonnull BugsnagEvent *)event {
}
return [[NSString alloc] initWithBytes:hex length:sizeof(hex) encoding:NSASCIIStringEncoding];
}

static NSString * Sysctl(const char *name) {
char buffer[32] = {0};
if (bsg_kssysctl_stringForName(name, buffer, sizeof buffer - 1)) {
return @(buffer);
} else {
return nil;
}
}
1 change: 1 addition & 0 deletions Bugsnag/Helpers/BSGRunContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ static void ResizeAndMapFile(int fd) {
}

memset(ptr, 0, SIZEOF_STRUCT);
mlock(ptr, SIZEOF_STRUCT);
bsg_runContext = ptr;
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ void *ksmachexc_i_handleExceptions(void *const userData) {
"Crash handling complete. Restoring original handlers.");
bsg_kscrashsentry_uninstall(BSG_KSCrashTypeAsyncSafe);
bsg_kscrashsentry_resumeThreads();

// Must run before endHandlingCrash unblocks secondary crashed threads.
BSG_KSCrash_Context *context = crashContext();
if (context->crash.attemptDelivery) {
BSG_KSLOG_DEBUG("Attempting delivery.");
context->crash.attemptDelivery();
}

bsg_kscrashsentry_endHandlingCrash();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ static size_t positive_double_to_string(const double value, char* dst, int max_s

// isnan() is basically ((x) != (x))
if(isnan(value)) {
strcpy(dst, "nan");
strlcpy(dst, "nan", 4);
return 3;
}

// isinf() is a compiler intrinsic.
if(isinf(value)) {
strcpy(dst, "inf");
strlcpy(dst, "inf", 4);
return 3;
}

Expand Down
2 changes: 1 addition & 1 deletion Bugsnag/Payload/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (instancetype)init {
#else
_name = @"Bugsnag Objective-C";
#endif
_version = @"6.24.0";
_version = @"6.25.0";
_url = @"https://github.com/bugsnag/bugsnag-cocoa";
_dependencies = @[];
}
Expand Down
51 changes: 24 additions & 27 deletions Bugsnag/include/Bugsnag/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,30 @@ BUGSNAG_EXTERN
*/
@property (nonatomic) BOOL sendLaunchCrashesSynchronously;

/**
* Whether Bugsnag should try to send crashing errors prior to app termination.
*
* Delivery will only be attempted for uncaught Objective-C exceptions and Mach
* exceptions, and while in progress will block the crashing thread for up to 3
* seconds.
*
* Delivery will be unreliable due to the necessary short timeout and potential
* memory corruption that caused the crashing error in the first place.
*
* If it fails prior to termination, delivery will be reattempted at next launch
* (the default behavior).
*
* Use of this feature is discouraged because it:
* - may cause the app to hang while delivery occurs and impact the hang rate
* reported in Xcode Organizer
* - will result in duplicate crashes in your dashboard for crashes that were
* fully sent but without receiving an HTTP response within the timeout
* - may prevent other crash reporters from detecting the crash.
*
* By default this value is false.
*/
@property (nonatomic) BOOL attemptDeliveryOnCrash;

/**
* The types of breadcrumbs which will be captured. By default, this is all types.
*/
Expand Down Expand Up @@ -488,33 +512,6 @@ BUGSNAG_EXTERN
*/
@property (nonatomic) BSGTelemetryOptions telemetry;

// =============================================================================
// MARK: - Experimental
// =============================================================================

/**
* Whether Bugsnag should try to send crashing errors prior to app termination.
*
* Delivery will only be attempted for uncaught Objective-C exceptions, and
* while in progress will block the crashing thread for up to 3 seconds.
*
* Delivery will be unreliable due to the necessary short timeout and potential
* memory corruption that caused the crashing error in the first place.
*
* If it fails prior to termination, delivery will be reattempted at next launch
* (the default behavior).
*
* Use of this feature is discouraged because it:
* - may cause the app to hang while delivery occurs and impact the hang rate
* reported in Xcode Organizer
* - will result in duplicate crashes in your dashboard for crashes that were
* fully sent but without receiving an HTTP response within the timeout
* - may prevent other crash reporters from detecting the crash.
*
* By default this value is false.
*/
@property (nonatomic) BOOL attemptDeliveryOnCrash;

// =============================================================================
// MARK: - Plugins
// =============================================================================
Expand Down
4 changes: 2 additions & 2 deletions Bugsnag/include/Bugsnag/BugsnagDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ BUGSNAG_EXTERN
@property (copy, nullable, nonatomic) NSString *manufacturer;

/**
* The model name of the device used
* The model ID of the device used, e.g. "iPhone14,1" or "MacBookPro17,1"
*/
@property (copy, nullable, nonatomic) NSString *model;

/**
* The model number of the device used
* The model number of the device used, e.g. "N841AP"
*/
@property (copy, nullable, nonatomic) NSString *modelNumber;

Expand Down
6 changes: 3 additions & 3 deletions BugsnagNetworkRequestPlugin.podspec.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "BugsnagNetworkRequestPlugin",
"version": "6.24.0",
"version": "6.25.0",
"summary": "Network request monitoring support for Bugsnag.",
"homepage": "https://bugsnag.com",
"license": "MIT",
"authors": {
"Bugsnag": "[email protected]"
},
"readme": "https://raw.githubusercontent.com/bugsnag/bugsnag-cocoa/v6.24.0/BugsnagNetworkRequestPlugin/README.md",
"readme": "https://raw.githubusercontent.com/bugsnag/bugsnag-cocoa/v6.25.0/BugsnagNetworkRequestPlugin/README.md",
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v6.24.0"
"tag": "v6.25.0"
},
"dependencies": {
"Bugsnag": "~> 6.13"
Expand Down
Loading

0 comments on commit 056b1c1

Please sign in to comment.