From 1f2996c6e86cb81def258a710ed236a198c3c42c Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Tue, 31 Jul 2018 11:50:52 +0100 Subject: [PATCH 1/7] build: run pod install for each example app --- .../project.pbxproj | 32 ------------------- examples/objective-c-ios/Podfile.lock | 8 ++--- examples/objective-c-osx/Podfile.lock | 8 ++--- .../objective-c-osx.xcodeproj/project.pbxproj | 32 ------------------- examples/swift-ios/Podfile.lock | 4 +-- .../bugsnag-example.xcodeproj/project.pbxproj | 32 ------------------- 6 files changed, 10 insertions(+), 106 deletions(-) diff --git a/examples/objective-c-ios/Bugsnag Test App.xcodeproj/project.pbxproj b/examples/objective-c-ios/Bugsnag Test App.xcodeproj/project.pbxproj index a0da6f7f6..d41737ee0 100644 --- a/examples/objective-c-ios/Bugsnag Test App.xcodeproj/project.pbxproj +++ b/examples/objective-c-ios/Bugsnag Test App.xcodeproj/project.pbxproj @@ -276,8 +276,6 @@ F40B874316AA233500676BB2 /* Frameworks */, F40B874416AA233500676BB2 /* Resources */, 5142A2F8286744A694BDB5BA /* Upload Bugsnag dSYM */, - 765F7485E02A01DA5E42AC27 /* [CP] Embed Pods Frameworks */, - E142138E1656CA8499F1E0A3 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -409,36 +407,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 765F7485E02A01DA5E42AC27 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Bugsnag Test App/Pods-Bugsnag Test App-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - E142138E1656CA8499F1E0A3 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Bugsnag Test App/Pods-Bugsnag Test App-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/examples/objective-c-ios/Podfile.lock b/examples/objective-c-ios/Podfile.lock index c36191120..b4a6b6cb3 100644 --- a/examples/objective-c-ios/Podfile.lock +++ b/examples/objective-c-ios/Podfile.lock @@ -1,16 +1,16 @@ PODS: - - Bugsnag (5.15.3) + - Bugsnag (5.16.0) DEPENDENCIES: - Bugsnag (from `../..`) EXTERNAL SOURCES: Bugsnag: - :path: ../.. + :path: "../.." SPEC CHECKSUMS: - Bugsnag: 49464c6c2fb7a2eb5a66064586c64a6e23454c04 + Bugsnag: 47bcc70b43e3c616ec35d30c2ca94497b957199f PODFILE CHECKSUM: 4c48f26cc704429f747c4af7a40e026b20fdc83e -COCOAPODS: 1.4.0 +COCOAPODS: 1.5.0 diff --git a/examples/objective-c-osx/Podfile.lock b/examples/objective-c-osx/Podfile.lock index fb54123ee..d1677f02b 100644 --- a/examples/objective-c-osx/Podfile.lock +++ b/examples/objective-c-osx/Podfile.lock @@ -1,16 +1,16 @@ PODS: - - Bugsnag (5.14.1) + - Bugsnag (5.16.0) DEPENDENCIES: - Bugsnag (from `../..`) EXTERNAL SOURCES: Bugsnag: - :path: ../.. + :path: "../.." SPEC CHECKSUMS: - Bugsnag: bc62bf437f55cfae29a4c836f29f9e8b64af3457 + Bugsnag: 47bcc70b43e3c616ec35d30c2ca94497b957199f PODFILE CHECKSUM: df3de31179198c85e1d68a7930eb894bbeb22744 -COCOAPODS: 1.3.1 +COCOAPODS: 1.5.0 diff --git a/examples/objective-c-osx/objective-c-osx.xcodeproj/project.pbxproj b/examples/objective-c-osx/objective-c-osx.xcodeproj/project.pbxproj index 309898785..cd844b513 100644 --- a/examples/objective-c-osx/objective-c-osx.xcodeproj/project.pbxproj +++ b/examples/objective-c-osx/objective-c-osx.xcodeproj/project.pbxproj @@ -165,8 +165,6 @@ 93BE1CCC1B62CC360016380C /* Frameworks */, 93BE1CCD1B62CC360016380C /* Resources */, D24AA2BFC04EE1A1916426C8 /* Upload Bugsnag dSYM */, - 3B550964C9496E4003E11717 /* [CP] Embed Pods Frameworks */, - 2DB50B6F565C5C917EEF01B4 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -252,36 +250,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 2DB50B6F565C5C917EEF01B4 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-objective-c-osx/Pods-objective-c-osx-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 3B550964C9496E4003E11717 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-objective-c-osx/Pods-objective-c-osx-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; AF12CC88EC2DA5EF6D40C883 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/examples/swift-ios/Podfile.lock b/examples/swift-ios/Podfile.lock index 9aeeb27fd..394a74938 100644 --- a/examples/swift-ios/Podfile.lock +++ b/examples/swift-ios/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Bugsnag (5.15.6) + - Bugsnag (5.16.0) DEPENDENCIES: - Bugsnag (from `../..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "../.." SPEC CHECKSUMS: - Bugsnag: ff5f5e3059e6a9c9d27a899f3bf3774067553483 + Bugsnag: 47bcc70b43e3c616ec35d30c2ca94497b957199f PODFILE CHECKSUM: 2107babfbfdb18f0288407b9d9ebd48cbee8661c diff --git a/examples/swift-ios/bugsnag-example.xcodeproj/project.pbxproj b/examples/swift-ios/bugsnag-example.xcodeproj/project.pbxproj index f2b27c64f..fe47ce667 100644 --- a/examples/swift-ios/bugsnag-example.xcodeproj/project.pbxproj +++ b/examples/swift-ios/bugsnag-example.xcodeproj/project.pbxproj @@ -170,8 +170,6 @@ D175F4B51ACDBD81009AFFB7 /* Frameworks */, D175F4B61ACDBD81009AFFB7 /* Resources */, 9AFEEED933DC82BFDDB374F6 /* Upload Bugsnag dSYM */, - C54E80312CD2DFF73A2EEB6C /* [CP] Embed Pods Frameworks */, - AF034E316E834BBEE8E209A4 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -295,36 +293,6 @@ shellScript = "fork do\n Process.setsid\n STDIN.reopen(\"/dev/null\")\n STDOUT.reopen(\"/dev/null\", \"a\")\n STDERR.reopen(\"/dev/null\", \"a\")\n\n require 'shellwords'\n\n Dir[\"#{ENV[\"DWARF_DSYM_FOLDER_PATH\"]}/*/Contents/Resources/DWARF/*\"].each do |dsym|\n system(\"curl -F dsym=@#{Shellwords.escape(dsym)} -F projectRoot=#{Shellwords.escape(ENV[\"PROJECT_DIR\"])} https://upload.bugsnag.com/\")\n end\nend\n"; showEnvVarsInLog = 0; }; - AF034E316E834BBEE8E209A4 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-bugsnag-example/Pods-bugsnag-example-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - C54E80312CD2DFF73A2EEB6C /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-bugsnag-example/Pods-bugsnag-example-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ From 050ae39e3d9c2e01e83c749a34c80fdc78b4f12d Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Tue, 31 Jul 2018 13:43:40 +0100 Subject: [PATCH 2/7] fix: deregister observers and listeners when a termination notification is received Previously observers and listeners were not deregistered when the application terminated. This is hypothesised to lead to allocations during dealloc, which could lead to rogue memory writes. --- Source/BugsnagNotifier.m | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Source/BugsnagNotifier.m b/Source/BugsnagNotifier.m index 66fe9b842..109942999 100644 --- a/Source/BugsnagNotifier.m +++ b/Source/BugsnagNotifier.m @@ -304,12 +304,13 @@ - (void)start { [self setupConnectivityListener]; [self updateAutomaticBreadcrumbDetectionSettings]; - + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [self watchLifecycleEvents:center]; #if TARGET_OS_TV [self.details setValue:@"tvOS Bugsnag Notifier" forKey:BSGKeyName]; + [self addTerminationObserver:UIApplicationWillTerminateNotification]; #elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE [self.details setValue:@"iOS Bugsnag Notifier" forKey:BSGKeyName]; @@ -339,6 +340,8 @@ - (void)start { [self batteryChanged:nil]; [self orientationChanged:nil]; + [self addTerminationObserver:UIApplicationWillTerminateNotification]; + #elif TARGET_OS_MAC [self.details setValue:@"OSX Bugsnag Notifier" forKey:BSGKeyName]; @@ -351,6 +354,8 @@ - (void)start { selector:@selector(willEnterBackground:) name:NSApplicationDidResignActiveNotification object:nil]; + + [self addTerminationObserver:NSApplicationWillTerminateNotification]; #endif _started = YES; @@ -359,10 +364,30 @@ - (void)start { [self willEnterForeground:self]; } +- (void)addTerminationObserver:(NSString *)name { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(stop:) + name:name + object:nil]; +} + +/** + * Removes observers and listeners to prevent allocations when the app is terminated + */ +- (void)stop:(id)sender { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [self.networkReachable stopWatchingConnectivity]; + +#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE + [UIDevice currentDevice].batteryMonitoringEnabled = NO; + [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; +#endif +} + - (void)watchLifecycleEvents:(NSNotificationCenter *)center { NSString *foregroundName; NSString *backgroundName; - + #if TARGET_OS_TV || TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE foregroundName = UIApplicationWillEnterForegroundNotification; backgroundName = UIApplicationWillEnterForegroundNotification; @@ -370,7 +395,7 @@ - (void)watchLifecycleEvents:(NSNotificationCenter *)center { foregroundName = NSApplicationWillBecomeActiveNotification; backgroundName = NSApplicationDidFinishLaunchingNotification; #endif - + [center addObserver:self selector:@selector(willEnterForeground:) name:foregroundName From 2b98e69602f4467f6fc375f8e1a02dc5257fc8ed Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Tue, 31 Jul 2018 14:00:59 +0100 Subject: [PATCH 3/7] docs: add changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db75d09c..adef54f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ========= +## 5.X.X (TBD) + +### Bug Fixes + +* Deregister notification observers and listeners before application termination [#301](https://github.com/bugsnag/bugsnag-cocoa/pull/301) + ## 5.16.0 (02 Jul 2018) This release alters the behaviour of the notifier to track sessions automatically. From a65f7038adc85c903af40a3b670210dabeffd6f2 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Tue, 31 Jul 2018 14:54:17 +0100 Subject: [PATCH 4/7] fix: add processor macro for tvos/macos --- Source/BugsnagNotifier.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/BugsnagNotifier.m b/Source/BugsnagNotifier.m index f09c1b162..f22f7453a 100644 --- a/Source/BugsnagNotifier.m +++ b/Source/BugsnagNotifier.m @@ -383,7 +383,8 @@ - (void)stop:(id)sender { [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.networkReachable stopWatchingConnectivity]; -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE +#if TARGET_OS_TV || TARGET_OS_MAC +#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE [UIDevice currentDevice].batteryMonitoringEnabled = NO; [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; #endif From 17328c68000e7ad56062fd7c5c0ac4607666f5ab Mon Sep 17 00:00:00 2001 From: Jamie Lynch Date: Thu, 2 Aug 2018 02:08:58 +0100 Subject: [PATCH 5/7] Refine mazerunner corruption assertion (#302) ## Goal Fix a flaky mazerunner scenario by changing the assertion for corrupted malloc ## Changeset Update the mazerunner step to account for an extra frame in the stacktrace, that can sometimes occur. --- features/steps/crash_assertion_steps.rb | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/features/steps/crash_assertion_steps.rb b/features/steps/crash_assertion_steps.rb index a525f42f3..bca7769b8 100644 --- a/features/steps/crash_assertion_steps.rb +++ b/features/steps/crash_assertion_steps.rb @@ -14,16 +14,23 @@ when "_nc_table_find_64" assert_equal(exception["errorClass"], "SIGSEGV") assert_equal(exception["message"], "Attempted to dereference null pointer.") - assert_equal(stacktrace[1]["method"], "notify_check") - assert_equal(stacktrace[2]["method"], "notify_check_tz") - assert_equal(stacktrace[3]["method"], "tzsetwall_basic") - assert_equal(stacktrace[4]["method"], "localtime_r") - assert_equal(stacktrace[5]["method"], "_populateBanner") - assert_equal(stacktrace[6]["method"], "_CFLogvEx2Predicate") - assert_equal(stacktrace[7]["method"], "_CFLogvEx3") - assert_equal(stacktrace[8]["method"], "_NSLogv") - assert_equal(stacktrace[9]["method"], "NSLog") - assert_equal(stacktrace[10]["method"], "-[CorruptMallocScenario run]") + + frame = 1 + + if stacktrace[frame]["method"] == "registration_node_find" + frame = 2 + end + + assert_equal(stacktrace[frame]["method"], "notify_check") + assert_equal(stacktrace[frame + 1]["method"], "notify_check_tz") + assert_equal(stacktrace[frame + 2]["method"], "tzsetwall_basic") + assert_equal(stacktrace[frame + 3]["method"], "localtime_r") + assert_equal(stacktrace[frame + 4]["method"], "_populateBanner") + assert_equal(stacktrace[frame + 5]["method"], "_CFLogvEx2Predicate") + assert_equal(stacktrace[frame + 6]["method"], "_CFLogvEx3") + assert_equal(stacktrace[frame + 7]["method"], "_NSLogv") + assert_equal(stacktrace[frame + 8]["method"], "NSLog") + assert_equal(stacktrace[frame + 9]["method"], "-[CorruptMallocScenario run]") else fail("The exception does not reflect malloc corruption") end From ccd05649a184781b6973b60d9bd01493febfc47c Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Thu, 2 Aug 2018 09:01:11 +0100 Subject: [PATCH 6/7] style: rename stop -> unsubscribeFromNotifications --- Source/BugsnagNotifier.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/BugsnagNotifier.m b/Source/BugsnagNotifier.m index f22f7453a..67cc4da40 100644 --- a/Source/BugsnagNotifier.m +++ b/Source/BugsnagNotifier.m @@ -371,7 +371,7 @@ - (void)start { - (void)addTerminationObserver:(NSString *)name { [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(stop:) + selector:@selector(unsubscribeFromNotifications:) name:name object:nil]; } @@ -379,7 +379,7 @@ - (void)addTerminationObserver:(NSString *)name { /** * Removes observers and listeners to prevent allocations when the app is terminated */ -- (void)stop:(id)sender { +- (void)unsubscribeFromNotifications:(id)sender { [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.networkReachable stopWatchingConnectivity]; From e0dee22bc1b1f7511aa247dbd2e966b7bf8bb3d5 Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Tue, 14 Aug 2018 13:28:12 +0100 Subject: [PATCH 7/7] v5.16.3 --- Bugsnag.podspec.json | 4 ++-- CHANGELOG.md | 2 +- Source/BugsnagNotifier.m | 2 +- VERSION | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Bugsnag.podspec.json b/Bugsnag.podspec.json index 0b53b359b..059183c5c 100644 --- a/Bugsnag.podspec.json +++ b/Bugsnag.podspec.json @@ -1,6 +1,6 @@ { "name": "Bugsnag", - "version": "5.16.2", + "version": "5.16.3", "summary": "Cocoa notifier for SDK for bugsnag.com", "homepage": "https://bugsnag.com", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v5.16.2" + "tag": "v5.16.3" }, "frameworks": ["Foundation", "SystemConfiguration"], "libraries": [ diff --git a/CHANGELOG.md b/CHANGELOG.md index e95f7722a..31b7f4cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ Changelog ========= -## 5.X.X (TBD) +## 5.16.3 (14 Aug 2018) ### Bug Fixes diff --git a/Source/BugsnagNotifier.m b/Source/BugsnagNotifier.m index 67cc4da40..598851709 100644 --- a/Source/BugsnagNotifier.m +++ b/Source/BugsnagNotifier.m @@ -41,7 +41,7 @@ #import #endif -NSString *const NOTIFIER_VERSION = @"5.16.2"; +NSString *const NOTIFIER_VERSION = @"5.16.3"; NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa"; NSString *const BSTabCrash = @"crash"; NSString *const BSAttributeDepth = @"depth"; diff --git a/VERSION b/VERSION index 9aa54ea30..01419b812 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.16.2 +5.16.3