aboutsummaryrefslogtreecommitdiff
path: root/nptl/descr.h
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/descr.h
parent699361795f6af887f26585962b8a73a394aab653 (diff)
downloadglibc-02189e8fb00c3c7f4e67476e21011a22c5dee707.zip
glibc-02189e8fb00c3c7f4e67476e21011a22c5dee707.tar.gz
glibc-02189e8fb00c3c7f4e67476e21011a22c5dee707.tar.bz2
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/descr.h')
-rw-r--r--nptl/descr.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/nptl/descr.h b/nptl/descr.h
index 3de9535..9d8297b 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -340,8 +340,9 @@ struct pthread
/* True if thread must stop at startup time. */
bool stopped_start;
- /* Formerly used for dealing with cancellation. */
- int parent_cancelhandling_unsed;
+ /* Indicate that a thread creation setup has failed (for instance the
+ scheduler or affinity). */
+ int setup_failed;
/* Lock to synchronize access to the descriptor. */
int lock;