Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ private bool WriteExceptionHelper(ReadOnlySpan<byte> key, Exception exception, i
if (!OpenValue(key, '{'))
return false;

if (!WriteHexValue("address"u8, (ulong)Unsafe.AsPointer(ref exception)))
ulong address = Unsafe.As<Exception, nuint>(ref exception);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the GC move the exception object between when we write this address in crashinfo and when the actual dump is generated?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can. IIRC, it was discussed somewhere. It is not 100% reliable pattern.

The diagnostic stack likes to use it. Tracing uses in multiple places, e.g.

public unsafe void RunningContinuation(int TaskID, object Object) { RunningContinuation(TaskID, (long)*((void**)Unsafe.AsPointer(ref Object))); }
.

if (!WriteHexValue("address"u8, address))
return false;

if (!WriteHexValue("hr"u8, exception.HResult))
Expand Down