Skip to content

C++ exceptions cannot cross JIT execution boundary on macOS ARM64 #3900

@taalexander

Description

@taalexander

Required prerequisites

  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

On macOS ARM64 (Apple Silicon), C++ exceptions thrown from JIT-compiled code cannot be caught by the host process. This causes a hard crash (libc++abi: terminating with uncaught exception) instead of graceful error handling.

This is tracked as llvm/llvm-project#49036 and has been open since 2021. A fix might have landed in LLVM 17 via the __unw_add_find_dynamic_unwind_sections callback API, but CUDA-Q is pinned to LLVM 16.0.6. We could try this out on upgrade.

Steps to reproduce the bug

Remove this decorator

@pytest.mark.skip_macos_arm64_jit
(or any other usage of this decorator)

Expected behavior

Tests should pass. Exceptions should be reported.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA-Q version: main
  • Python version: 3.11-3.13
  • C++ compiler: Clang 17 (local), clang 16 cuda q
  • Operating system: Mac Os 26.2 (Tahoe)

Suggestions

Options may be to upgrade to LLVM 17+ (which may or may not fix this bug). Or to add manual exception handling across the JIT boundary (which may not be possible) to intercept exceptions and forward in Cuda-Q.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions