Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit dc4ad69

Browse files
committed
Add example of how to crash from a pinvoke
1 parent e0ac3c6 commit dc4ad69

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

main/build/MacOSX/monostub.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@
227227
}
228228
}
229229

230+
extern "C" void crash_me()
231+
{
232+
void *p = (void*)0x12345;
233+
*(int *)p = 0;
234+
}
235+
230236
int
231237
main (int argc, char **argv)
232238
{

main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,16 @@ protected override void Run ()
201201
Thread.Sleep (TimeSpan.FromMinutes(2));
202202
}
203203
}
204+
205+
class InduceNativePInvokeCrashHandler : CommandHandler
206+
{
207+
[DllImport ("__Internal")]
208+
static extern void crash_me ();
209+
210+
protected override void Run ()
211+
{
212+
crash_me ();
213+
}
214+
}
204215
#endif
205216
}

main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/ReliabilityDiagnostics.addin.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<Command id="PerformanceDiagnosticsAddIn.InduceHang"
1616
defaultHandler="PerformanceDiagnosticsAddIn.InduceHangHandler"
1717
_label="Induce Hang" />
18+
<Command id="PerformanceDiagnosticsAddIn.InduceNativePInvokeCrash"
19+
defaultHandler="PerformanceDiagnosticsAddIn.InduceNativePInvokeCrashHandler"
20+
_label="Induce PInvoke Crash" />
1821

1922
</Extension>
2023
<Extension path="/MonoDevelop/Ide/MainMenu/Help">
@@ -24,6 +27,7 @@
2427
<CommandItem id="PerformanceDiagnosticsAddIn.InduceManagedCrash" />
2528
<CommandItem id="PerformanceDiagnosticsAddIn.InduceNativeCrash" />
2629
<CommandItem id="PerformanceDiagnosticsAddIn.InduceHang" />
30+
<CommandItem id="PerformanceDiagnosticsAddIn.InduceNativePInvokeCrash" />
2731

2832
</ItemSet>
2933
</Extension>

0 commit comments

Comments
 (0)