Skip to content

Commit 4b3726d

Browse files
author
rhamlett_microsoft
committed
More fixes to Native Crash option, plus some CSS tweaks to allow more log lines to be visible without scrolling.
1 parent 05fb2bf commit 4b3726d

File tree

2 files changed

+8
-28
lines changed

2 files changed

+8
-28
lines changed

src/PerfProblemSimulator/Services/CrashService.cs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -257,36 +257,16 @@ private void ExecuteAccessViolation()
257257
/// </remarks>
258258
private void ExecuteNativeCrash()
259259
{
260-
_logger.LogCritical("Triggering native crash - attempting multiple methods!");
260+
_logger.LogCritical("Triggering native crash via RaiseException (FAIL_FAST_EXCEPTION)!");
261261

262-
// Method 1: RtlFailFast - should bypass all handlers
263-
try
264-
{
265-
_logger.LogCritical("Attempting RtlFailFast...");
266-
const uint FAST_FAIL_FATAL_APP_EXIT = 7;
267-
RtlFailFast(FAST_FAIL_FATAL_APP_EXIT);
268-
}
269-
catch
270-
{
271-
_logger.LogWarning("RtlFailFast was caught (unexpected!)");
272-
}
273-
274-
// Method 2: Direct null pointer dereference via unsafe code
275-
_logger.LogCritical("RtlFailFast didn't crash, trying unsafe null dereference...");
276-
unsafe
277-
{
278-
int* nullPtr = (int*)0;
279-
*nullPtr = 42; // This WILL crash
280-
}
281-
282-
// Method 3: If somehow we're still alive, use FailFast
283-
_logger.LogCritical("Unsafe code didn't crash?! Using Environment.FailFast...");
284-
Environment.FailFast("NativeCrash fallback: RtlFailFast and unsafe null dereference both failed!");
262+
// Use RaiseException with FAIL_FAST_EXCEPTION code (0xC0000409)
263+
// This is the same exception code used by __fastfail and is reliably captured
264+
// by Windows Error Reporting and Azure Crash Monitoring
265+
const uint STATUS_STACK_BUFFER_OVERRUN = 0xC0000409; // __fastfail exception code
266+
const uint EXCEPTION_NONCONTINUABLE = 0x1;
267+
RaiseException(STATUS_STACK_BUFFER_OVERRUN, EXCEPTION_NONCONTINUABLE, 0, IntPtr.Zero);
285268
}
286269

287-
[DllImport("ntdll.dll")]
288-
private static extern void RtlFailFast(uint Code);
289-
290270
/// <summary>
291271
/// Allocates memory until the process runs out and crashes.
292272
/// </summary>

src/PerfProblemSimulator/wwwroot/css/dashboard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ body {
536536
}
537537

538538
.log-container {
539-
max-height: 375px;
539+
max-height: 575px;
540540
overflow-y: auto;
541541
font-family: 'Cascadia Code', 'Consolas', monospace;
542542
font-size: 0.8125rem;

0 commit comments

Comments
 (0)