proxy-wasm-cpp-host icon indicating copy to clipboard operation
proxy-wasm-cpp-host copied to clipboard

Add support for C++ exceptions

Open PiotrSikora opened this issue 5 years ago • 7 comments

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.

PiotrSikora avatar Dec 10 '20 10:12 PiotrSikora

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.

kyessenov avatar Dec 10 '20 22:12 kyessenov

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.

PiotrSikora avatar Dec 14 '20 09:12 PiotrSikora

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 :\

mathetake avatar Mar 10 '21 05:03 mathetake

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: https://github.com/emscripten-core/emscripten/issues/12475), unless there is an urgent business need for it.

PiotrSikora avatar Mar 10 '21 06:03 PiotrSikora

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.

https://github.com/emscripten-core/emscripten/issues/11233#issuecomment-635332613

mathetake avatar Apr 26 '21 01:04 mathetake

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

mathetake avatar Sep 22 '21 01:09 mathetake

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

raakella avatar Jan 05 '23 06:01 raakella