Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store unhandled exception info on stack in Native AOT #84871

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Changes from 1 commit
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 @@ -248,6 +248,19 @@ internal static void FailFast(string message, Exception? exception, RhFailFastRe
outputMessage = message;
}

if (outputMessage != null)
agocke marked this conversation as resolved.
Show resolved Hide resolved
{
// Try to save the exception stack trace in a buffer on the stack. If the exception is too large, we'll truncate it.
const int MaxStack = 1024;
Span<char> exceptionStack = stackalloc char[MaxStack];

int length = Math.Max(MaxStack, outputMessage.Length);
outputMessage.AsSpan().Slice(0, length).CopyTo(exceptionStack);
agocke marked this conversation as resolved.
Show resolved Hide resolved
// Fill the rest of the buffer with nulls
if (length < MaxStack)
exceptionStack.Slice(length).Clear();
agocke marked this conversation as resolved.
Show resolved Hide resolved
}

agocke marked this conversation as resolved.
Show resolved Hide resolved
Internal.Console.Error.Write(prefix);
if (outputMessage != null)
Internal.Console.Error.Write(outputMessage);
Expand Down