Module: xenomai-head
Branch: master
Commit: b7e96a418a5dd69819c4afe8cf3b9ff3acc01b60
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=b7e96a418a5dd69819c4afe8cf3b9ff3acc01b60

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Jan 25 19:39:57 2011 +0100

skins/common: fix segv in the sigaction+linuxthreads+gdb case

Mask the SIGSHADOW signal in order to avoid a suspected race causing
a segmentation fault with linuxthreads library if a signal is pending
when calling sigaction to install a handler for this signal, and when
running under gdb.

---

 src/skins/common/sigshadow.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/skins/common/sigshadow.c b/src/skins/common/sigshadow.c
index ddb4a52..39f7d13 100644
--- a/src/skins/common/sigshadow.c
+++ b/src/skins/common/sigshadow.c
@@ -62,15 +62,22 @@ static void xeno_sigshadow_handler(int sig, siginfo_t *si, 
void *ctxt)
 void xeno_sigshadow_install(void)
 {
        struct sigaction new_sigshadow_action;
+       sigset_t saved_sigset;
+       sigset_t mask_sigset;
+
+       sigemptyset(&mask_sigset);
+       sigaddset(&mask_sigset, SIGSHADOW);
 
        new_sigshadow_action.sa_flags = SA_SIGINFO | SA_RESTART;
        new_sigshadow_action.sa_sigaction = xeno_sigshadow_handler;
        sigemptyset(&new_sigshadow_action.sa_mask);
 
+       pthread_sigmask(SIG_BLOCK, &mask_sigset, &saved_sigset);
        sigaction(SIGSHADOW,
                  &new_sigshadow_action, &xeno_saved_sigshadow_action);
        if (!(xeno_saved_sigshadow_action.sa_flags & SA_NODEFER))
                sigaddset(&xeno_saved_sigshadow_action.sa_mask, SIGSHADOW);
+       pthread_sigmask(SIG_SETMASK, &saved_sigset, NULL);
 }
 
 void xeno_sigshadow_install_once(void)


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to