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

Report unhandled exceptions/FailFast in event log #98152

Merged
merged 3 commits into from
Feb 12, 2024

Conversation

MichalStrehovsky
Copy link
Member

Fixes #73998.

EventReporter is basically taken from eventreporter.cpp in the VM.

Cc @tommcdon @mikem8361 @dotnet/ilc-contrib

Fixes dotnet#73998.

`EventReporter` is basically taken from eventreporter.cpp in the VM.
@ghost
Copy link

ghost commented Feb 8, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #73998.

EventReporter is basically taken from eventreporter.cpp in the VM.

Cc @tommcdon @mikem8361 @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@ghost ghost assigned MichalStrehovsky Feb 8, 2024
_description.AppendLine("unknown");
}

_description.Append("CoreCLR Version: ");
Copy link
Contributor

Choose a reason for hiding this comment

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

CoreCLR?

Copy link
Member Author

Choose a reason for hiding this comment

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

CoreCLR?

Don't see a good enough reason to break people who parse this.

if (exception != null && reason is not RhFailFastReason.AssertionFailure)
{
reporter.AddDescription($"{exception.GetType()}: {exception.Message}");
reporter.AddStackTrace(exception.StackTrace);
Copy link
Member

Choose a reason for hiding this comment

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

Computing the stack trace is a complicated operation and it is likely to crash again when things are corrupted. The existing console printing code is written in a way so that there is at least something printed to the console in this case, giving people clue what might have happened.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved it after writing to console.

Comment on lines 18 to 20
// Maximum size for a string in event log entry
#define MAX_SIZE_EVENTLOG_ENTRY_STRING 0x8000 // decimal 32768

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Maximum size for a string in event log entry
#define MAX_SIZE_EVENTLOG_ENTRY_STRING 0x8000 // decimal 32768

// permissible length of the string and event header became 32K, resulting in strings becoming
// shorter in length. Hence, the change in size.
// An event entry comprises of string to be written and event header information.
// The total permissible length of the string and event header is 32K.
#define MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA 0x7C62 // decimal 31842
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#define MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA 0x7C62 // decimal 31842
#define MAX_SIZE_EVENTLOG_ENTRY_STRING 0x7C62 // decimal 31842

Comment on lines 91 to 107
const int MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA = 0x7C62; // decimal 31842

// Continue to append to the buffer until we are full
if (!_bufferFull)
{
_description.AppendLine(s);

// Truncate the buffer if we have exceeded the limit based upon the OS we are on
if (_description.Length > MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA)
{
// Load the truncation message
string truncate = "\nThe remainder of the message was truncated.\n";

int truncCount = truncate.Length;

// Go back "truncCount" characters from the end of the string.
int ext = MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA - truncCount;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const int MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA = 0x7C62; // decimal 31842
// Continue to append to the buffer until we are full
if (!_bufferFull)
{
_description.AppendLine(s);
// Truncate the buffer if we have exceeded the limit based upon the OS we are on
if (_description.Length > MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA)
{
// Load the truncation message
string truncate = "\nThe remainder of the message was truncated.\n";
int truncCount = truncate.Length;
// Go back "truncCount" characters from the end of the string.
int ext = MAX_SIZE_EVENTLOG_ENTRY_STRING_WINVISTA - truncCount;
const int MAX_SIZE_EVENTLOG_ENTRY_STRING = 0x7C62; // decimal 31842
// Continue to append to the buffer until we are full
if (!_bufferFull)
{
_description.AppendLine(s);
// Truncate the buffer if we have exceeded the limit based upon the OS we are on
if (_description.Length > MAX_SIZE_EVENTLOG_ENTRY_STRING)
{
// Load the truncation message
string truncate = "\nThe remainder of the message was truncated.\n";
int truncCount = truncate.Length;
// Go back "truncCount" characters from the end of the string.
int ext = MAX_SIZE_EVENTLOG_ENTRY_STRING - truncCount;

@tommcdon
Copy link
Member

tommcdon commented Feb 8, 2024

cc @Hoyos @mikem8361

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@MichalStrehovsky MichalStrehovsky merged commit 271f5f1 into dotnet:main Feb 12, 2024
148 of 153 checks passed
@MichalStrehovsky MichalStrehovsky deleted the exn branch February 12, 2024 19:14
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NativeAOT: Reporting of the exceptions in the event viewer
4 participants