开发者

Question regarding multiple threads and segfaults

What happens when two threads of the same pr开发者_运维问答ocess running on different logical cpu hit a seg fault?


Default action is for the process to exit. If you handle the segfault, I suppose you could try to arrange for just the thread where it happened to terminate. However, since the only things which cause a segfault to occur naturally (as opposed to raise or kill) stem from undefined behavior, the program is in an indeterminate state and you can't rely on being able to recover anything.


Normal handling of a Segmentation Fault involves the termination of the process. That means that both of them are terminated.


I think the default action on all major OSes is to terminate the process. However, you could conceivably install (e.g using signal) an alternate handler that only terminated the thread. Of course, once you have a segmentation fault, behavior typically becomes undefined, and attempting to continue is risky.


Signals generated due to illegal execution are handled synchronously by the kernel. So even if both the threads generate seg fault at the same time, only one gets thru'.


The segfault handler is called for the process. If you don't do anything special, the OS will kill the process and reclaim its resources.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜