Skip to content

New crash handler in macOS? #118823

Closed
Closed

Description

@richlander

This experience seems to be new. I wrote a test app with an intentional crash scenario to test something. This is what I saw. Not a problem, just (A) is this new?, and (B) FYI.

Image

Activity

  1. changed the title [-]New crash handler in macOS 26[/-] [+]New crash handler in macOS 26?[/+] on Aug 17, 2025
  2. added
    untriaged
    on Aug 17, 2025
  3. added
    needs-area-label
    on Aug 17, 2025
  4. added
    area-ExceptionHandling-coreclr
    and removed
    needs-area-label
    on Aug 17, 2025
  5. vcsjones commented on Aug 17, 2025

    @vcsjones
    Member

    This looks like the Swift crash handler. https://www.swift.org/blog/swift-5.9-backtraces/

    The post goes on to say that the debugger is off by default for macOS, maybe they turned it on by default in macOS 26.

    If we don't like it I suppose we could set environment variable SWIFT_BACKTRACE to enable=no on start up, if the environment variable is unset. That way folks can turn it on if they want.

  6. vcsjones commented on Aug 17, 2025

    @vcsjones
    Member

    From Apple's docs:

    Note that the runtime will not install its signal handlers for a signal if it finds that there is already a handler for that signal. Similarly if something else has already configured an alternate signal stack, it will leave that stack alone.

    This is interesting and I wonder if Apple's exception handling will collide with our own, since it mentions configuring alternate stacks.

    cc @janvorli

  7. richlander commented on Aug 18, 2025

    @richlander
    MemberAuthor
  8. richlander commented on Aug 18, 2025

    @richlander
    MemberAuthor

    FYI: I am now one beta build back. Another came out (I think) last week. I'm in the middle of a project and have been delaying upgrading until I get to a clean spot (and can push my changes). It's possible that the beheavior changes in the next build. perhaps someone else has that installed.

  9. vcsjones commented on Aug 18, 2025

    @vcsjones
    Member

    I can reproduce this on Preview 7. Any second change managed exception causes it. A simple 1-line program:

    throw new Exception("hello!");

    Will invoke the Swift debugger.

    This is with .NET 10 preview 7 and macOS 26 preview 7. I am not using a debug build of the runtime.

    Doing SWIFT_BACKTRACE="enable=no" dotnet run does indeed disable the swift backtrace handler.

  10. jeffhandley commented on Aug 18, 2025

    @jeffhandley
    Member

    @jkotas / @agocke Where in the product would we go about disabling this by default? I presume we'd need to introduce our own ENV var to disable us disabling it too.

  11. vcsjones commented on Aug 18, 2025

    @vcsjones
    Member

    Where in the product would we go about disabling this by default?

    I don't know how easy this is to do by environment variable. This needs to be done very early in application startup - before the managed Main. I can't disable it programmatically from my own program.

  12. richlander commented on Aug 18, 2025

    @richlander
    MemberAuthor

    FYI: I believe this is ship-stopper issue.

  13. 41 remaining items

  14. steveisok commented on Sep 10, 2025

    @steveisok
    Member

    We pinged Apple about this and the swift backtrace handler running was an intentional change. The guidance they provided is to either have a dummy signal handler that just returns or set the SWIFT_BACKTRACE env variable to enable=no. They did say it was important to note that the environment variable is only checked on process startup (when the static initializers for the swift runtime execute).

    For our case, it does not seem like there's any harm in using the environment variable.

  15. MichalPetryka commented on Sep 10, 2025

    @MichalPetryka
    Contributor

    For our case, it does not seem like there's any harm in using the environment variable.

    One noticeable issue would be custom hosting scenarios like Unity, since they'd need to set the variable themselves since dotnet might only be loaded later on in program lifetime.

  16. vcsjones commented on Sep 10, 2025

    @vcsjones
    Member

    One noticeable issue would be custom hosting scenarios like Unity, since they'd need to set the variable themselves since dotnet might only be loaded later on in program lifetime.

    Regardless of environment variable or signal handler, it seems to me it needs to be something to host does. The host can set the environment variable (early) or it can set the signal handler. If the runtime attempts to set the signal handler or environment variable then it might be too late - the swift runtime will have already set up BacktraceInitializer.

  17. agocke commented on Sep 22, 2025

    @agocke
    Member

    This should be mitigated by #119920, but I don't know if we want to do something else for .NET 11.

  18. modified the milestones: 10.0.0, 11.0.0 on Sep 22, 2025
  19. jkotas commented on Sep 22, 2025

    @jkotas
    Member

    something else for .NET 11.

    Duplicate or related to #113707

  20. LIJIAOLONG96 commented on Nov 20, 2025

    @LIJIAOLONG96

    So, has this issue been fixed in the latest .NET 10 version? I have currently found that Avalonia .NET 10 applications cannot be captured by global exception handlers when they crash, and I'm not sure if this is caused by the same reason.

  21. agocke commented on Nov 20, 2025

    @agocke
    Member

    @869570967 The behavior in .NET 10 is the same as in .NET 9, so it should be fixed in that sense.

  22. jkotas commented on Nov 20, 2025

    @jkotas
    Member

    I have currently found that Avalonia .NET 10 applications cannot be captured by global exception handlers

    You may want to create a new issue about this with details. It is not clear what you mean by "global exception handlers".

  23. LIJIAOLONG96 commented on Nov 20, 2025

    @LIJIAOLONG96

    I have currently found that Avalonia .NET 10 applications cannot be captured by global exception handlers

    You may want to create a new issue about this with details. It is not clear what you mean by "global exception handlers".

    AppDomain.CurrentDomain.UnhandledException
    TaskScheduler.UnobservedTaskException
    I mean, these two events stopped working on macOS.

  24. jkotas commented on Nov 20, 2025

    @jkotas
    Member

    Open an issue on this with repro steps and the behavior that you are seeing.

  25. LIJIAOLONG96 commented on Nov 20, 2025

    @LIJIAOLONG96

    ok

  26. locked and limited conversation to collaborators on Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ExceptionHandling-coreclros-macos

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions