[NativeAOT] Print OOM message before Abort() on Linux#125311
Open
Copilot wants to merge 27 commits into
Open
Conversation
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix out of memory reporting on Linux for NativeAOT
[NativeAOT] Print OOM message before Abort() on Linux
Mar 8, 2026
Member
|
Please add a unit test to src/tests |
Member
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Contributor
Author
Added a new |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jkotas
reviewed
May 28, 2026
jkotas
reviewed
May 28, 2026
jkotas
reviewed
May 28, 2026
jkotas
reviewed
May 29, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux, NativeAOT processes terminating due to
OutOfMemoryException(e.g. withDOTNET_GCHeapHardLimitset) printed onlyAbortedwith no diagnostic context.Root cause
RuntimeExceptionHelpers.FailFastdetects the preallocated OOM exception viaminimalFailFast = (exception == PreallocatedOutOfMemoryException.Instance)and skips all stderr output to avoid heap allocations — leaving the user with no indication of why the process died.Fix
In the
minimalFailFastpath, print a hardcoded OOM message to stderr before callingAbort(). The write is wrapped intry/catch {}so a secondary allocation failure silently falls through to the existing abort path.Before:
AbortedAfter:
Out of memory.Test
Added a new
OomHandlingsmoke test insrc/tests/baseservices/exceptions/OutOfMemoryException/. The test spawns itself as a subprocess withDOTNET_GCHeapHardLimit=20000000(32 MB) set, waits for the subprocess to run out of memory, and verifies thatOutOfMemoryExceptionappears in stderr. This covers both the preallocated OOM path (the fix) and the existing unhandled-exception path. The test is skipped on mobile and browser platforms that do not support process spawning.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.