From patchwork Sat Mar 17 21:53:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 26353 Received: (qmail 50314 invoked by alias); 17 Mar 2018 21:53:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50305 invoked by uid 89); 17 Mar 2018 21:53:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=Hx-languages-length:1991, H*r:sk:static-, Hx-spam-relays-external:sk:static-, H*RU:sk:static- X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [hurd, commited] hurd: Fix getting signal thread stack layout for fork Date: Sat, 17 Mar 2018 22:53:38 +0100 Message-Id: <20180317215338.17665-1-samuel.thibault@ens-lyon.org> * hurd/hurdsig.c: Include . (_hurdsig_init): Call pthread_getattr_np and pthread_attr_getstack to get the signal thread stack layout. --- ChangeLog | 6 ++++++ hurd/hurdsig.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 175bcafe66..7f4721b06e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-03-17 Samuel Thibault + + * hurd/hurdsig.c: Include . + (_hurdsig_init): Call pthread_getattr_np and pthread_attr_getstack to + get the signal thread stack layout. + 2018-03-16 Samuel Thibault * sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 4f5bb9a8da..198546fbb3 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -20,6 +20,7 @@ #include #include /* For `struct mutex'. */ +#include #include #include @@ -1297,7 +1298,24 @@ _hurdsig_init (const int *intarray, size_t intarraysize) values all zero so they'll be ignored. */ #pragma weak cthread_fork #pragma weak cthread_detach - cthread_detach (cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); +#pragma weak pthread_getattr_np +#pragma weak pthread_attr_getstack + cthread_t thread = cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, + 0); + cthread_detach (thread); + + if (pthread_getattr_np) + { + /* Record signal thread stack layout for fork() */ + pthread_attr_t attr; + void *addr; + size_t size; + + pthread_getattr_np ((pthread_t) thread, &attr); + pthread_attr_getstack (&attr, &addr, &size); + __hurd_sigthread_stack_base = (uintptr_t) addr; + __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size; + } /* XXX We need the thread port for the signal thread further on in this thread (see hurdfault.c:_hurdsigfault_init).