From ce8a16ba39fa2296fb5c1271648f89d0e25d88fa Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Fri, 22 Dec 2023 11:04:08 -0800 Subject: [PATCH 1/2] Fix JSON crashinfo exception object address --- .../nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs index 43c098161607ed..2059211a72aae2 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs @@ -172,7 +172,8 @@ private bool WriteExceptionHelper(ReadOnlySpan key, Exception exception, i if (!OpenValue(key, '{')) return false; - if (!WriteHexValue("address"u8, (ulong)Unsafe.AsPointer(ref exception))) + ulong address = *(nuint*)Unsafe.AsPointer(ref exception); + if (!WriteHexValue("address"u8, address)) return false; if (!WriteHexValue("hr"u8, exception.HResult)) From b1a4c5a1f88875306388c0bebffc2c5df1949956 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Fri, 22 Dec 2023 11:55:10 -0800 Subject: [PATCH 2/2] Code review feedback --- .../nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs index 2059211a72aae2..cf7594163a406d 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs @@ -172,7 +172,7 @@ private bool WriteExceptionHelper(ReadOnlySpan key, Exception exception, i if (!OpenValue(key, '{')) return false; - ulong address = *(nuint*)Unsafe.AsPointer(ref exception); + ulong address = Unsafe.As(ref exception); if (!WriteHexValue("address"u8, address)) return false;