Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Remove the need for exception handling in the VM files (to prepare for wasm)

Open necessarily-equal opened this issue 3 years ago • 3 comments

There are some things to do to avoid relying on exceptions in the VM. First some files from daemon are imported inside the VM and use exceptions in parts where they likely shouldn't. Notably:

  • [ ] daemon/src/shared/VMMain.cpp
  • [ ] daemon/src/engine/qcommon/files.cpp
  • [ ] RmlUi is built with exceptions enabled

If someone could tackle these it would be great.

necessarily-equal avatar Dec 11 '22 10:12 necessarily-equal

I already tried to do this previously, so there shouldn't be much left.

src/engine/qcommon/files.cpp is built only in the engine.

RmlUi has to be built with exceptions for the time being because it's one of those things where it's unsafe to mix different flags. There's no throw in the codebase so it shouldn't pose an issue. (There's one library that does though: Freetype uses setjmp/longjmp error handling.)

So the one thing we could do something about now is changing the implementation of Sys::Drop in NaCl to get rid of the VMMain.cpp case.

slipher avatar Dec 11 '22 22:12 slipher

Pretty sure freetype has been ported to work with wasm right?

DolceTriade avatar Dec 12 '22 03:12 DolceTriade

So this probably won't be needed for WASM. I think WASM implementations either

  • (a) don't support non-local jumps up the stack at all, which is a no-go for Lua which really needs either setjmp/longjmp or exceptions (unlike Freetype where we could just accept that a font loading error is fatal).
  • or (b) will gain full exception support.

But we do need it for NaCl Saigo, which has setjmp/longjmp, but not exceptions. The current cases are

  • tinygettext internally throws an exception if a .po file is not valid. I think we can accept this being a fatal error since those are supposed to be machine-generated.
  • The VMMain stuff needs a bit of adjustment. Currently we use some tricks so that we we get an exception, we can both print the exception message and crash in a way that produces a stack trace. With Saigo we will have to give up printing the exception message and only crash.

slipher avatar Feb 21 '25 22:02 slipher