Skip to content

[wasm coreclr] exception handling #113694

Open

Description

@radekdoulik

most of EH will be handled by the interpreter. we might still need few parts for the native code

Activity

  1. ghost added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Mar 19, 2025
  2. changed the title [-]exception handling[/-] [+][wasm coreclr] exception handling[/+] on Mar 19, 2025
  3. added and removed
    untriagedNew issue has not been triaged by the area owner
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Mar 19, 2025
  4. self-assigned this
    on Mar 19, 2025
  5. dotnet-policy-service commented on Mar 19, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing
    See info in area-owners.md if you want to be subscribed.

  6. added this to the 10.0.0 milestone on Apr 1, 2025
  7. modified the milestones: 10.0.0, 11.0.0 on Aug 5, 2025
  8. pavelsavara commented on Aug 29, 2025

    @pavelsavara
    Member

    In transitions to native code in Mono we use C++ catch via LLVM, that translates to WASM catch instruction/block.

    This would not be necessary for JSImport/JSExport interop, because we catch and marshal exceptions in JS.

    But any exceptions in native code called by P/Invoke/Qcall/Fcall/Icall (including emscripten and browser errors) would trap if not handled. So I think we will need something similar when we call out.

    mono_llvm_cpp_catch_exception (MonoLLVMInvokeCallback cb, gpointer arg, gboolean *out_thrown)
    {
    *out_thrown = FALSE;
    try {
    cb (arg);
    } catch (int*) {
    *out_thrown = TRUE;
    }
    }

    EMSCRIPTEN_KEEPALIVE void
    mono_jiterp_begin_catch (void *exception_object) {
    __cxa_begin_catch (exception_object);
    }
    EMSCRIPTEN_KEEPALIVE void
    mono_jiterp_end_catch (void) {
    return __cxa_end_catch ();
    }

  9. pavelsavara commented on Apr 10, 2026

    @pavelsavara
    Member

    @janvorli said JS exception in DLLImport is undefined behavior - he is right
    but the lived reality is that people have native code that calls JS directly and propagates JS exceptions.
    The key trick there is to abort posix/"process" when it happens, so that you don't get crazy behavior from subsequent calls into broken/corrupted system and silly bug reports.

  10. dotnet-policy-service commented on Apr 15, 2026

    @dotnet-policy-service
    Contributor

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

  11. pavelsavara commented on Jul 14, 2026

    @pavelsavara
    Member

    Is there anything remaining for this one @radekdoulik ?

  12. modified the milestones: 11.0.0, 12.0.0 on Jul 15, 2026
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

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions