throw exception when Java JNI experiences segmentation fault

Deadly 提交于 2020-01-06 07:20:17

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/5395337/throw-exception-when-java-jni-experiences-segmentation-fault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!