diff options
author | William Pitcock <nenolod@dereferenced.org> | 2017-08-01 23:14:40 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2017-08-01 23:14:40 +0000 |
commit | dec938e95626c49baa8b1d853158d588f6f7c634 (patch) | |
tree | 8c355aabd49d8d440ad97031f90e15d0e233ee87 /main/musl | |
parent | ce133a64851ee1338f287d21b6620d148b0c876b (diff) | |
download | aports-dec938e95626c49baa8b1d853158d588f6f7c634.tar.bz2 aports-dec938e95626c49baa8b1d853158d588f6f7c634.tar.xz |
main/musl: crash instead of follow glibc behaviour on pthread_join() UB as discussed on #musl
Diffstat (limited to 'main/musl')
-rw-r--r-- | main/musl/2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch | 18 | ||||
-rw-r--r-- | main/musl/APKBUILD | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/main/musl/2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch b/main/musl/2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch index 4fc5c05095..f376c929af 100644 --- a/main/musl/2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch +++ b/main/musl/2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch @@ -1,32 +1,32 @@ -From 602a22f1b626f84e9f7117940c06f4890c584d2a Mon Sep 17 00:00:00 2001 +From bda7e30e6bf5e20269a08775574c9d75b27c4387 Mon Sep 17 00:00:00 2001 From: William Pitcock <nenolod@dereferenced.org> -Date: Tue, 1 Aug 2017 22:23:25 +0000 +Date: Tue, 1 Aug 2017 23:08:49 +0000 Subject: [PATCH] thread: do not attempt to join detached threads in pthread_join() A thread which is detached releases it's resources and TCB upon thread termination. Therefore a thread which is detached is not joinable as any underlying futex will not -be incremented, resulting in a deadlock. Accordingly, we return EINVAL instead of -attempting to wait on a detached thread. +be incremented, resulting in a deadlock. Accordingly, POSIX defines calling +pthread_join() on a detached thread as undefined behaviour. -Other pthread implementations such as glibc NPTL and FreeBSD also reject attempts -to join detached threads with EINVAL. +We attempt, where possible, to detect attempts to join detached threads and crash +instead, to bring the undefined behaviour to the programmer's attention. --- src/thread/pthread_join.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thread/pthread_join.c b/src/thread/pthread_join.c -index 52111489..7c4bde23 100644 +index 52111489..b7175c09 100644 --- a/src/thread/pthread_join.c +++ b/src/thread/pthread_join.c @@ -11,6 +11,7 @@ int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at) __pthread_testcancel(); __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); if (cs == PTHREAD_CANCEL_ENABLE) __pthread_setcancelstate(cs, 0); -+ if (t->detached) r = EINVAL; ++ if (t->detached) a_crash(); while ((tmp = t->tid) && r != ETIMEDOUT && r != EINVAL) r = __timedwait_cp(&t->tid, tmp, CLOCK_REALTIME, at, 0); __pthread_setcancelstate(cs, 0); -- -2.13.2 +2.13.3 diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD index 551614b1b8..5891546e85 100644 --- a/main/musl/APKBUILD +++ b/main/musl/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Timo Teräs <timo.teras@iki.fi> pkgname=musl pkgver=1.1.16 -pkgrel=16 +pkgrel=17 pkgdesc="the musl c library (libc) implementation" url="http://www.musl-libc.org/" arch="all" @@ -259,7 +259,7 @@ dde4bb6c877d4fdf976e3ffea5d0a4a48f365708c488ceeaa4dcc29296820517aebbfa3b0527d74d 6e0a65d4023b4d2b0a971f1dbb5017fe7aedf7c663c0f9971841a4739758826c323cd0856a1591cfd874df35e8b96f1248eda029a9cd56987c36178a32b1f0ee 0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch 7e4c703e57a3564cd3ee1d5334b806cbe654355179ba55d4d25361dfc555eb4a7d081d80d64fdaff8476949afd04558d278b124d1fb108080beaa5ba2f8ce2b9 1000-implement-strftime-GNU-extension-padding-specifiers-.patch 2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch -0771b1f9995ca3e687073c8c7562b6ddb395282f6f922556d6d06a37ea4e205479df550162908bd18706b6a2585239fc50cc5a00e9672af399c7376aff4efb3f 2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch +76330dfff60b2a8703ddc38f378995334ab0fa56e31e499937a4b4dfd8ff4a0bf1f8108174e8f863810de5cc28ff4c50656b886ee468605072bc55310a077624 2001-thread-do-not-attempt-to-join-detached-threads-in-pt.patch 8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig 062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c 0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c |