Catch Rapier panics at FFI boundary to prevent crash#477
Catch Rapier panics at FFI boundary to prevent crash#477hexadexxa wants to merge 3 commits intoryanhcode:mainfrom
Conversation
… boundary Wrap Rapier tick/step in catch_unwind to prevent JVM abort
|
Should also fix issue #431 if it's the same issue |
|
this is a really bad idea. the rust panics are panics for a reason; they indicate a fatal error in the physics engine (there is no mechanism for handling recoverable errors at present), ignoring these fatal errors will just invite more UB or breakages in later calls or physics steps, making everything harder to debug. |
|
i think it still propagates to a server crash, just through a jvm exception |
At present it simply seems to ignore panics altogether (hence my comments). Clearing the physics state and raising a JVM exception with a rust backtrace would be nice but the present version of the pr just makes debugging native crashes harder. |
|
yeah, ignoring the panics is an absolute no-go. I'd be happy if we raised a JVM exception with the details from the panic and unrecoverably crashed the server |
|
I see, I'll try doing that later |
Catch Rapier panics at FFI boundary and throw JVM RuntimeException
|
Updated. Now catches the panic and throws a RuntimeException with the panic message via env.throw_new, so the server crashes with a proper crash report |
Rapier internal assertions can panic during the physics step. Since the
JNI functions use
extern "system", this unwinds across the FFI boundaryand aborts the JVM.
Wraps
pipeline.step()andtick()incatch_unwindso panics arecaught and the tick is skipped instead of crashing.