Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sigprocmask() causing segfault

Are there any well known reasons for sigprocmask() to segfault when used in a multithreaded application?

I have an application that creates multiple threads using clone(). I have determined that for some reason when I use sigprocmask it segfaults (not all the time though). From the backtrace() it also seems like the segfault is occuring when I use sigprocmask() after a siglongjmp().

Any ideas?

like image 469
TripShock Avatar asked Jul 15 '26 13:07

TripShock


1 Answers

Check the second and third arguments. If they are not NULL, ensure that they are each a valid pointer to a sigset_t.

Note that sigprocmask() is only officially defined for a single-threaded process. A multithreaded process should use pthread_sigmask() instead, which takes the same arguments although it returns the error code rather than using errno.

like image 166
mark4o Avatar answered Jul 18 '26 04:07

mark4o