about summary refs log tree commit diff
path: root/nptl/pthread_rwlockattr_init.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-05-21 14:19:23 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-06-09 15:16:45 -0300
commit02189e8fb00c3c7f4e67476e21011a22c5dee707 (patch)
tree3baa2efe20a4e2eba0b4bd303040936e8e5b5525 /nptl/pthread_rwlockattr_init.c
parent699361795f6af887f26585962b8a73a394aab653 (diff)
downloadglibc-02189e8fb00c3c7f4e67476e21011a22c5dee707.tar.gz
glibc-02189e8fb00c3c7f4e67476e21011a22c5dee707.tar.xz
glibc-02189e8fb00c3c7f4e67476e21011a22c5dee707.zip
nptl: Deallocate the thread stack on setup failure (BZ #19511)
To setup either the thread scheduling parameters or affinity,
pthread_create enforce synchronization on created thread to wait until
its parent either release PD ownership or send a cancellation signal if
a failure occurs.

However, cancelling the thread does not deallocate the newly created
stack since cancellation expects that a pthread_join to deallocate any
allocated thread resouces (threads stack or TLS).

This patch changes on how the thread resource is deallocate in case of
failure to be synchronous, where the creating thread will signal the
created thread to exit early so it could be joined.  The creating thread
will be reponsible for the resource cleanup before returning to the
caller.

To signal the creating thread that a failure has occured, an unused
'struct pthread' member, parent_cancelhandling_unsed, now indicates
whether the setup has failed so creating thread can proper exit.

This strategy also simplifies by not using thread cancellation and
thus not running libgcc_so load in the signal handler (which is
avoided in thread cancellation since 'pthread_cancel' is the one
responsible to dlopen libgcc_s).  Another advantage is since the
early exit is move to first step at thread creation, the signal
mask is not already set and thus it can not act on change ID setxid
handler.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Diffstat (limited to 'nptl/pthread_rwlockattr_init.c')
0 files changed, 0 insertions, 0 deletions