Skip to content

Add support for C++ exceptions #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PiotrSikora opened this issue Dec 10, 2020 · 7 comments
Open

Add support for C++ exceptions #116

PiotrSikora opened this issue Dec 10, 2020 · 7 comments

Comments

@PiotrSikora
Copy link
Member

Host implementation should support running Wasm code that was built with C++ exceptions.

Notably, those functions must be implemented:

  • __cxa_begin_catch,
  • __cxa_end_catch,
  • __cxa_free_exception,
  • __cxa_get_exception_ptr,
  • __cxa_uncaught_exceptions,
  • __cxa_find_matching_catch_2, __cxa_find_matching_catch_3, __cxa_find_matching_catch_4,
  • __resumeException,
  • getTempRet0,
  • invoke_ii, invoke_iii, invoke_iiii, invoke_iiiii, invoke_v, invoke_vi, invoke_vii, invoke_viii, invoke_viiii,
  • llvm_eh_typeid_for.
@kyessenov
Copy link
Collaborator

kyessenov commented Dec 10, 2020

It looks like a large ABI extension. Is there a way around it? It feels odd to include libc++ ABI for non c++ code. Thinking of it as RPC, it looks very chatty.

@PiotrSikora
Copy link
Member Author

PiotrSikora commented Dec 14, 2020

Only the host implementations (i.e. Envoy and other proxies that wish to support C++ exceptions) need to implement this, so it wouldn't leak to non-C++ SDKs at all.

I couldn't find a way around it using various settings in Emscripten.

@mathetake
Copy link
Contributor

Is emscripten C++ exception supported in the native Wasmtime or any other native WASI runtime? If so, I would like to see their implementation but I couldn't find :\

@PiotrSikora
Copy link
Member Author

I don't think so. But it's unclear if this is worth the trouble. We probably should wait until Wasm Exceptions are supported (see some discussion here: emscripten-core/emscripten#12475), unless there is an urgent business need for it.

@mathetake
Copy link
Contributor

I see that emcc experimentally supports -fwasm-exception flag in LLVM(https://reviews.llvm.org/D67208) and the staging V8 has already implementation for that(https://bugs.chromium.org/p/v8/issues/detail?id=6577) based on the Wasm exception proposal.

emscripten-core/emscripten#11233 (comment)

@mathetake
Copy link
Contributor

now the latest V8 has been shipped with Wasm's native exception proposal and the latest Emscripten support for that. Maybe worth a try

@raakella
Copy link

raakella commented Jan 5, 2023

Just wanted to check if anybody is able to get exceptions working in c++ wasm extensions in envoy. It is not working for us in envoy 1.15-alpha.9a54da0237daa254460ee2e92592ac0eeb602c56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants