This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix libgomp crash without TLS (PR42616)
- From: Richard Henderson <rth at redhat dot com>
- To: Varvara Rainchik <varvara dot s dot rainchik at gmail dot com>, gcc-patches at gcc dot gnu dot org, jakub at redhat dot com
- Date: Fri, 29 Aug 2014 10:40:57 -0700
- Subject: Re: Fix libgomp crash without TLS (PR42616)
- Authentication-results: sourceware.org; auth=none
- References: <CAAp9h93CTb_oZ-y4-GgJUN7wTkjUajWMzGD+eyY43wJHQFw5eg at mail dot gmail dot com>
On 08/06/2014 03:05 AM, Varvara Rainchik wrote:
> * libgomp.h (gomp_thread): For non TLS case create thread data.
> * team.c (create_non_tls_thread_data): New function.
>
>
> ---
> diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
> index a1482cc..cf3ec8f 100644
> --- a/libgomp/libgomp.h
> +++ b/libgomp/libgomp.h
> @@ -479,9 +479,15 @@ static inline struct gomp_thread *gomp_thread (void)
> }
> #else
> extern pthread_key_t gomp_tls_key;
> +extern struct gomp_thread *create_non_tls_thread_data (void);
> static inline struct gomp_thread *gomp_thread (void)
> {
> - return pthread_getspecific (gomp_tls_key);
> + struct gomp_thread *thr = pthread_getspecific (gomp_tls_key);
> + if (thr == NULL)
> + {
> + thr = create_non_tls_thread_data ();
> + }
> + return thr;
> }
This should never happen.
The thread-specific data is set in gomp_thread_start and initialize_team.
Where are you getting a call to gomp_thread that hasn't been through one of
those functions?
r~