Skip to content

[native aot] Unhandled exceptions are not printed to console #91298

Closed

Description

@jkotas

Compile and run with nativeaot on current main:

throw new Exception("My unhandled exception");

Expected result

Unhandled exception message is printed to console.

Actual result

No message printed to console

Activity

  1. ghost added
    untriaged
    on Aug 29, 2023
  2. removed
    untriaged
    on Aug 29, 2023
  3. jkotas commented on Aug 29, 2023

    @jkotas
    MemberAuthor

    Looks like a regression from #88034. @janvorli Could you please take a look?

  4. janvorli commented on Aug 30, 2023

    @janvorli
    Member

    The problem is really caused by the #88034, specifically by moving the

    prevControlPC = frameIter.ControlPC;
    prevOriginalPC = frameIter.OriginalControlPC;

    from after to before the

    It results in call to the UnhandledExceptionFailFastViaClasslib with prevOriginalPC that's one level up the call stack, in the native wmain. That further causes the InternalCalls.RhpGetClasslibFunctionFromCodeAddress to return null, as the address is not in managed code.

    I can make this part of the change specific to coreclr, that fixes the problem. However, I would like to check what was the reason for moving it, it seems that for coreclr the only place where it matters is the arm64 code path here:

    #if TARGET_ARM64
    && (frameIter.ControlPC == prevControlPC)
    #endif

  5. added this to the 9.0.0 milestone on Aug 31, 2023
  6. added a commit that references this issue on Aug 31, 2023
    0947cc2
  7. ghost added
    in-pr
    on Aug 31, 2023
  8. ghost removed
    in-pr
    on Sep 5, 2023
  9. added a commit that references this issue on Sep 5, 2023
    6de0e22
  10. ghost locked as resolved and limited conversation to collaborators on Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions