UTSASRG / Scaler

GNU General Public License v2.0
4 stars 0 forks source link

Error handling improvement #22

Closed GammaPi closed 2 years ago

GammaPi commented 2 years ago
  1. Replace exception with error code
    • Consideration: It is hard for other collaborators to write exception safety code.
  2. More robust error message
    • Debugging Scaler is super hard. We should provide abundant error messages to help error diagnosis.
GammaPi commented 2 years ago

Implemented in 9b2522d54e8896cd91e9821c4258b5c8e73dbb38 to 93329844a04cb15f56ebe0cf7dd4f2d00ce7ea7a.

GammaPi commented 2 years ago

For setjmp and longjump, we can solve by simply saving the caller address.

GammaPi commented 2 years ago

For exception, we need to create proxy personality functions.

GammaPi commented 2 years ago

https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html

GammaPi commented 2 years ago

https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#%E4%B8%AD%E6%96%87%E7%89%88

GammaPi commented 2 years ago

http://maskray.me/static/2020-11-22-cpp-exception-handling/slide.pdf

GammaPi commented 2 years ago

It's not that complicated to handle this. We can simply verify whether the stack unwind happened during posthook. If true, we need to also rewind the return stack so that the return address is corrected.

This solution borrows the idea of #63

Let's call this stack unwinding detection.

GammaPi commented 2 years ago

Closing. Implemented in v0.2.1.