public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-5859] libgcc: block signals when releasing split-stack memory Date: Tue, 8 Dec 2020 18:18:27 +0000 (GMT) [thread overview] Message-ID: <20201208181828.16B413857C70@sourceware.org> (raw) https://gcc.gnu.org/g:f41dd93ade24f22f8cd1863129ab20c821000134 commit r11-5859-gf41dd93ade24f22f8cd1863129ab20c821000134 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Dec 8 10:17:16 2020 -0800 libgcc: block signals when releasing split-stack memory * generic-morestack-thread.c (free_segments): Block signals during thread exit. Diff: --- libgcc/generic-morestack-thread.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libgcc/generic-morestack-thread.c b/libgcc/generic-morestack-thread.c index 83a65501272..fd391bb2e1f 100644 --- a/libgcc/generic-morestack-thread.c +++ b/libgcc/generic-morestack-thread.c @@ -38,6 +38,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef inhibit_libc #include <errno.h> +#include <signal.h> #include <pthread.h> #include "generic-morestack.h" @@ -54,6 +55,9 @@ extern int pthread_key_create (pthread_key_t *, void (*) (void *)) extern int pthread_setspecific (pthread_key_t, const void *) __attribute__ ((weak)); +extern int pthread_sigmask (int, const sigset_t *, sigset_t *) + __attribute__ ((weak)); + /* The key for the list of stack segments to free when the thread exits. This is created by pthread_key_create. */ @@ -70,6 +74,16 @@ static pthread_once_t create_key_once = PTHREAD_ONCE_INIT; static void free_segments (void* arg) { + /* We must block signals in case the signal handler tries to split + the stack. We leave them blocked while the thread exits. */ + if (pthread_sigmask) + { + sigset_t mask; + + sigfillset (&mask); + pthread_sigmask (SIG_BLOCK, &mask, NULL); + } + __morestack_release_segments ((struct stack_segment **) arg, 1); }
reply other threads:[~2020-12-08 18:18 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201208181828.16B413857C70@sourceware.org \ --to=ian@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).