throw exception when Java JNI experiences segmentation fault
We have code running JNI in a separate thread. We occasionally 开发者_如何转开发get segmentation faults while developing that we need to debug, but because the code is running in a separate thread the seg-fault isn't reported. Instead the thread essentially dies without warning making debugging difficult.
I would like to be able to either detect a segmentation fault and/or throw an exception when a seg fault occurs so that we have some indication that a thread has died without warning. Is there any way to detect segmentation faults in this manner?
On windows, use SetUnhandledExceptionFilter or use a __try __except
construct to catch exceptions in the thread. On POSIX platforms, install a handler for SIGSEGV
with sigaction
精彩评论