Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb nostop SIGSEGV on a specific thread

I have a program that purposely segfaults on one threads, but I have a problem that the other thread is segfaulting, I'd like to catch it with GDB, I saw that I can:

handle SIGSEGV nostop noprint

but I'd like to do that only on the thread that purposely does that.. is it possible?

I'll explain: I have 2 threads, one thread is segfaulting(and recovers(mprotect read only and then releasing memory)), that works fine, the other thread does something else, but sadly, there is a bug and it is segfaulting, I want to catch that segfault, and not the other ones that occur in the other thread.

like image 603
Alon Avatar asked Apr 29 '14 11:04

Alon


1 Answers

As I know, depending on the OS, and I assume linux for my answer and the answer is 'NO'!

Posix exceptions can have a sigmask per thread but only one handler per task. So it is not possible to set different handling for each thread. sigaction will handle it for the complete process. So I see no way for gdb to change this.

like image 71
Klaus Avatar answered Sep 28 '22 01:09

Klaus