diff --git a/integration-test/ios.Tests.ps1 b/integration-test/ios.Tests.ps1 index 3c38696f69..7ec6eee0b5 100644 --- a/integration-test/ios.Tests.ps1 +++ b/integration-test/ios.Tests.ps1 @@ -99,9 +99,8 @@ Describe 'iOS app (, )' -ForEach @( $result.HasErrors() | Should -BeFalse $result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`"" - # TODO: fix redundant SIGABRT (#3954) - { $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`"" } | Should -Throw - { $result.Envelopes() | Should -HaveCount 1 } | Should -Throw + $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"(EXC_[A-Z_]+|SIG[A-Z]+)`"" + $result.Envelopes() | Should -HaveCount 1 } It 'captures native crash ()' { @@ -112,7 +111,7 @@ Describe 'iOS app (, )' -ForEach @( } $result.HasErrors() | Should -BeFalse - $result.Envelopes() | Should -AnyElementMatch "`"type`":`"EXC_[A-Z_]+`"" + $result.Envelopes() | Should -AnyElementMatch "`"type`":`"(EXC_[A-Z_]+|SIG[A-Z]+)`"" $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`"" $result.Envelopes() | Should -HaveCount 1 } @@ -126,12 +125,7 @@ Describe 'iOS app (, )' -ForEach @( $result.HasErrors() | Should -BeFalse $result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`"" - # TODO: fix redundant EXC_BAD_ACCESS in Release (#3954) - if ($configuration -eq 'Release') { - { $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`"" } | Should -Throw - } else { - $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`"" - $result.Envelopes() | Should -HaveCount 1 - } + $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"(EXC_[A-Z_]+|SIG[A-Z]+)`"" + $result.Envelopes() | Should -HaveCount 1 } } diff --git a/scripts/build-sentry-cocoa.sh b/scripts/build-sentry-cocoa.sh index 6e18143f1a..f3ef2b7558 100755 --- a/scripts/build-sentry-cocoa.sh +++ b/scripts/build-sentry-cocoa.sh @@ -50,7 +50,8 @@ xcodebuild archive -project Sentry.xcodeproj \ -sdk "$ios_sdk" \ -archivePath ./Carthage/output-ios.xcarchive \ SKIP_INSTALL=NO \ - BUILD_LIBRARY_FOR_DISTRIBUTION=YES + BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ + GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SENTRY_CRASH_MANAGED_RUNTIME=1' ./scripts/remove-architectures.sh ./Carthage/output-ios.xcarchive arm64e xcodebuild archive -project Sentry.xcodeproj \ -scheme Sentry \ @@ -58,7 +59,8 @@ xcodebuild archive -project Sentry.xcodeproj \ -sdk "$ios_simulator_sdk" \ -archivePath ./Carthage/output-iossimulator.xcarchive \ SKIP_INSTALL=NO \ - BUILD_LIBRARY_FOR_DISTRIBUTION=YES + BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ + GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SENTRY_CRASH_MANAGED_RUNTIME=1' xcodebuild -create-xcframework \ -framework ./Carthage/output-ios.xcarchive/Products/Library/Frameworks/Sentry.framework \ -framework ./Carthage/output-iossimulator.xcarchive/Products/Library/Frameworks/Sentry.framework \ @@ -73,7 +75,8 @@ xcodebuild archive -project Sentry.xcodeproj \ -destination 'generic/platform=macOS,variant=Mac Catalyst' \ -archivePath ./Carthage/output-maccatalyst.xcarchive \ SKIP_INSTALL=NO \ - BUILD_LIBRARY_FOR_DISTRIBUTION=YES + BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ + GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SENTRY_CRASH_MANAGED_RUNTIME=1' ./scripts/remove-architectures.sh ./Carthage/output-maccatalyst.xcarchive arm64e xcodebuild -create-xcframework \ -framework ./Carthage/output-maccatalyst.xcarchive/Products/Library/Frameworks/Sentry.framework \ diff --git a/src/Sentry/Platforms/Cocoa/RuntimeMarshalManagedExceptionIntegration.cs b/src/Sentry/Platforms/Cocoa/RuntimeMarshalManagedExceptionIntegration.cs index 396221cb79..5397a2c0d4 100644 --- a/src/Sentry/Platforms/Cocoa/RuntimeMarshalManagedExceptionIntegration.cs +++ b/src/Sentry/Platforms/Cocoa/RuntimeMarshalManagedExceptionIntegration.cs @@ -43,6 +43,12 @@ internal void Handle(object sender, MarshalManagedExceptionEventArgs e) // This is likely a terminal exception so try to send the crash report before shutting down _hub?.Flush(); + + // The Xamarin runtime will call abort() after this handler returns, which raises + // SIGABRT. Tell SentryCrash to ignore it on this thread so we don't get a duplicate + // native crash event for a managed exception we've already captured. + const int SIGABRT = 6; + SentryCocoaHybridSdk.IgnoreNextSignal(SIGABRT); } } }