views:

74

answers:

5

What happens when two threads of the same process running on different logical cpu hit a seg fault?

A: 

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.

Nathon
`fork` creates a new process, not a thread.
Matthew Flaschen
Haha, whoops. Silly me.
Nathon
+1  A: 

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.

Matthew Flaschen
+2  A: 

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

doron
+2  A: 

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.

R..
A: 

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'.

aeh