On Tue, Jun 30, 2026 at 10:27:39PM +0800, LIU Hao wrote: > Attached are four patches for libgomp.
Please don't include 4 different patches in one mail. > From f641adac6d35f241118fc715ffc40b2b82146a60 Mon Sep 17 00:00:00 2001 > From: LIU Hao <[email protected]> > Date: Tue, 30 Jun 2026 10:17:12 +0800 > Subject: [PATCH 9201/9204] libgomp/team: Fix a race condition > > `gomp_thread_start_data::handle` is set by `pthread_create()`. If the thread > starts execution before `pthread_create()` stores the handle, it may be left > uninitialized. > > The fix is to obtain the handle from `pthread_self()`. > > libgomp/ChangeLog: > > * team.c (gomp_thread_start): Get reflexive handle with > `pthread_self()`. > > Signed-off-by: LIU Hao <[email protected]> Please make this conditional on the targets which actually need it. E.g. with glibc there is a guarantee that the handle is stored before the thread is spawned and so this patch just slows down performance critical part of code. Given that nobody reported a problem with this on other arches (musl, darwin, ...), perhaps the race condition doesn't exist there either. > --- > libgomp/team.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libgomp/team.c b/libgomp/team.c > index 5282a3133ba9..08c28a5b8765 100644 > --- a/libgomp/team.c > +++ b/libgomp/team.c > @@ -93,7 +93,7 @@ gomp_thread_start (void *xdata) > thr->num_teams = data->num_teams; > thr->team_num = data->team_num; > #ifdef GOMP_NEEDS_THREAD_HANDLE > - thr->handle = data->handle; > + thr->handle = pthread_self (); > #endif > #if !(defined HAVE_TLS || defined USE_EMUTLS) > pthread_setspecific (gomp_tls_key, thr); Jakub
