diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-07-28 22:01:49 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-02 00:00:03 +0200 |
commit | 70ff58ced45edf0e3483eddbb61203037bdfdaaa (patch) | |
tree | e13a7e5d61fe5b6048df5ece378f78c65c1ef41b /htl/pt-self.c | |
parent | c622ac1b8662908b595ec1a19e401ad6a629f52c (diff) | |
download | glibc-70ff58ced45edf0e3483eddbb61203037bdfdaaa.zip glibc-70ff58ced45edf0e3483eddbb61203037bdfdaaa.tar.gz glibc-70ff58ced45edf0e3483eddbb61203037bdfdaaa.tar.bz2 |
htl: Let pthread_self and cancellability called early
When applications redirect some functions they might get called before
libpthread is fully initialized. They may still expected pthread_self
and cancellable functions to work, so cope with such calls in that
situation.
Diffstat (limited to 'htl/pt-self.c')
-rw-r--r-- | htl/pt-self.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/htl/pt-self.c b/htl/pt-self.c index 6fd3c98..e05ec69 100644 --- a/htl/pt-self.c +++ b/htl/pt-self.c @@ -24,7 +24,13 @@ pthread_t __pthread_self (void) { - struct __pthread *self = _pthread_self (); + struct __pthread *self; + + if (___pthread_self == NULL) + /* We are not initialized yet, we are the first thread. */ + return 1; + + self = _pthread_self (); assert (self != NULL); return self->thread; |