Skip to content

Commit 170787d

Browse files
Merge ea231f7 into 1ceeca5
2 parents 1ceeca5 + ea231f7 commit 170787d

27 files changed

+1922
-20
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Capturing fatal CPPExceptions via hooking into cxa_throw when enabling `options.experimental.enableUnhandledCPPExceptionsV2 = true` (#5256)
8+
39
## 8.52.0
410

511
### Features

Samples/SentrySampleShared/SentrySampleShared/SentrySDKWrapper.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public struct SentrySDKWrapper {
130130

131131
// Experimental features
132132
options.experimental.enableFileManagerSwizzling = !SentrySDKOverrides.Other.disableFileManagerSwizzling.boolValue
133+
options.experimental.enableUnhandledCPPExceptionsV2 = true
133134
}
134135

135136
func configureInitialScope(scope: Scope) -> Scope {

Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -890,13 +890,13 @@
890890
</constraints>
891891
</view>
892892
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="40A-vG-dFA">
893-
<rect key="frame" x="0.0" y="134" width="320" height="268"/>
893+
<rect key="frame" x="0.0" y="134" width="320" height="274.5"/>
894894
<subviews>
895895
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="fn9-mQ-2PY">
896-
<rect key="frame" x="0.0" y="0.0" width="320" height="140"/>
896+
<rect key="frame" x="0.0" y="0.0" width="320" height="146.5"/>
897897
<subviews>
898898
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="Q2k-6Y-RnD">
899-
<rect key="frame" x="0.0" y="0.0" width="160" height="140"/>
899+
<rect key="frame" x="0.0" y="0.0" width="160" height="146.5"/>
900900
<subviews>
901901
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NFC-V3-lgW">
902902
<rect key="frame" x="0.0" y="0.0" width="160" height="28"/>
@@ -907,31 +907,31 @@
907907
</connections>
908908
</button>
909909
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Llv-Yz-cwF">
910-
<rect key="frame" x="0.0" y="28" width="160" height="28"/>
910+
<rect key="frame" x="0.0" y="29.5" width="160" height="28"/>
911911
<fontDescription key="fontDescription" type="system" pointSize="13"/>
912912
<state key="normal" title="Capture NSException"/>
913913
<connections>
914914
<action selector="captureNSException:" destination="QmU-DD-itF" eventType="touchUpInside" id="Gdl-wk-dUU"/>
915915
</connections>
916916
</button>
917917
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wJ4-gS-64G" userLabel="fatalError">
918-
<rect key="frame" x="0.0" y="56" width="160" height="28"/>
918+
<rect key="frame" x="0.0" y="59.5" width="160" height="28"/>
919919
<fontDescription key="fontDescription" type="system" pointSize="13"/>
920920
<state key="normal" title="Throw FatalError"/>
921921
<connections>
922922
<action selector="captureFatalError:" destination="QmU-DD-itF" eventType="touchUpInside" id="dM5-xq-lrm"/>
923923
</connections>
924924
</button>
925925
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ulu-26-dyP" userLabel="fatalDuplicateKeyError">
926-
<rect key="frame" x="0.0" y="84" width="160" height="28"/>
926+
<rect key="frame" x="0.0" y="89" width="160" height="28"/>
927927
<fontDescription key="fontDescription" type="system" pointSize="13"/>
928928
<state key="normal" title="Fatal Duplicate Key Error"/>
929929
<connections>
930930
<action selector="throwFatalDuplicateKeyError:" destination="QmU-DD-itF" eventType="touchUpInside" id="kze-Yw-k8f"/>
931931
</connections>
932932
</button>
933933
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NYx-6R-0bb">
934-
<rect key="frame" x="0.0" y="112" width="160" height="28"/>
934+
<rect key="frame" x="0.0" y="118.5" width="160" height="28"/>
935935
<fontDescription key="fontDescription" type="system" pointSize="13"/>
936936
<state key="normal" title="OOM crash"/>
937937
<connections>
@@ -941,7 +941,7 @@
941941
</subviews>
942942
</stackView>
943943
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="2CV-VI-MDY">
944-
<rect key="frame" x="160" y="0.0" width="160" height="140"/>
944+
<rect key="frame" x="160" y="0.0" width="160" height="146.5"/>
945945
<subviews>
946946
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zbo-2T-1Zm">
947947
<rect key="frame" x="0.0" y="0.0" width="160" height="28"/>
@@ -953,24 +953,33 @@
953953
</connections>
954954
</button>
955955
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="s6w-E3-5yE" userLabel="DiskWriteException">
956-
<rect key="frame" x="0.0" y="35" width="160" height="28"/>
956+
<rect key="frame" x="0.0" y="28" width="160" height="28"/>
957957
<fontDescription key="fontDescription" type="system" pointSize="13"/>
958958
<state key="normal" title="DiskWriteException"/>
959959
<connections>
960960
<action selector="diskWriteException:" destination="QmU-DD-itF" eventType="touchUpInside" id="p74-qC-kH7"/>
961961
</connections>
962962
</button>
963963
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NNd-Ec-zXw">
964-
<rect key="frame" x="0.0" y="70.5" width="160" height="28"/>
964+
<rect key="frame" x="0.0" y="56" width="160" height="28"/>
965965
<accessibility key="accessibilityConfiguration" label="crashTheApp"/>
966966
<fontDescription key="fontDescription" type="system" pointSize="13"/>
967967
<state key="normal" title="Crash the app"/>
968968
<connections>
969969
<action selector="crash:" destination="QmU-DD-itF" eventType="touchUpInside" id="qlZ-bL-KUT"/>
970970
</connections>
971971
</button>
972+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ptW-5o-Xrh" userLabel="Unhandled C++ Exception">
973+
<rect key="frame" x="0.0" y="84" width="160" height="28"/>
974+
<accessibility key="accessibilityConfiguration" label="crashTheApp"/>
975+
<fontDescription key="fontDescription" type="system" pointSize="13"/>
976+
<state key="normal" title="Unhandled C++ Exception"/>
977+
<connections>
978+
<action selector="unhandledCppException:" destination="QmU-DD-itF" eventType="touchUpInside" id="T1y-uf-e08"/>
979+
</connections>
980+
</button>
972981
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wJs-Av-cg2">
973-
<rect key="frame" x="0.0" y="105.5" width="160" height="34.5"/>
982+
<rect key="frame" x="0.0" y="112" width="160" height="34.5"/>
974983
<state key="normal" title="Button"/>
975984
<buttonConfiguration key="configuration" style="plain" title="Use-after-free"/>
976985
<connections>
@@ -982,7 +991,7 @@
982991
</subviews>
983992
</stackView>
984993
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1zm-ho-TCr">
985-
<rect key="frame" x="0.0" y="140" width="320" height="128"/>
994+
<rect key="frame" x="0.0" y="146.5" width="320" height="128"/>
986995
<constraints>
987996
<constraint firstAttribute="height" constant="128" id="lc6-97-p3W"/>
988997
</constraints>
@@ -1172,7 +1181,7 @@
11721181
<rect key="frame" x="0.0" y="336" width="152" height="38"/>
11731182
<subviews>
11741183
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YhG-k9-4vd">
1175-
<rect key="frame" x="0.0" y="0.0" width="76" height="38"/>
1184+
<rect key="frame" x="0.0" y="0.0" width="78" height="38"/>
11761185
<accessibility key="accessibilityConfiguration" identifier="io.sentry.ui-test.button.show-widget"/>
11771186
<state key="normal" title="Button"/>
11781187
<buttonConfiguration key="configuration" style="plain" title="Show Widget">
@@ -1183,7 +1192,7 @@
11831192
</connections>
11841193
</button>
11851194
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fqi-kr-TkL">
1186-
<rect key="frame" x="76" y="0.0" width="76" height="38"/>
1195+
<rect key="frame" x="78" y="0.0" width="74" height="38"/>
11871196
<accessibility key="accessibilityConfiguration" identifier="io.sentry.ui-test.button.hide-widget"/>
11881197
<state key="normal" title="Button"/>
11891198
<buttonConfiguration key="configuration" style="plain" title="Hide Widget">

Samples/iOS-Swift/iOS-Swift/ErrorsViewController.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class ErrorsViewController: UIViewController {
5555
}
5656
}
5757

58+
@IBAction func unhandledCppException(_ sender: Any) {
59+
let cpp = CppWrapper()
60+
cpp.throwCPPException()
61+
}
62+
5863
// swiftlint:disable force_unwrapping
5964
@IBAction func unwrapCrash(_ sender: UIButton) {
6065
highlightButton(sender)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "CppCode.hpp"
2+
#include <stdexcept>
3+
4+
void
5+
Sentry::CppCode::throwCPPException(void)
6+
{
7+
throw std::invalid_argument("Invalid Argument.");
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef CppCode_h
2+
#define CppCode_h
3+
#if defined __cplusplus
4+
5+
# include <stdio.h>
6+
7+
namespace Sentry {
8+
class CppCode {
9+
public:
10+
void throwCPPException();
11+
};
12+
}
13+
14+
#endif /* __cplusplus */
15+
#endif /* CppSample_hpp */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface CppWrapper : NSObject
4+
- (void)throwCPPException;
5+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#import "CppWrapper.h"
2+
#import "CppCode.hpp"
3+
#import <Foundation/Foundation.h>
4+
5+
@implementation CppWrapper
6+
7+
- (void)throwCPPException
8+
{
9+
Sentry::CppCode cpp;
10+
cpp.throwCPPException();
11+
}
12+
13+
@end

Samples/iOS-Swift/iOS-Swift/Tools/iOS-Swift-Bridging-Header.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#import "CppWrapper.h"
12
#import "SentryBenchmarking.h"
23
#import "SentryExposure.h"
34
#import "SentryUIApplication.h"

0 commit comments

Comments
 (0)