From: Rich Felker Date: Thu, 16 Aug 2018 16:16:36 +0000 (-0400) Subject: fix pthread_create return value with PTHREAD_EXPLICIT_SCHED X-Git-Tag: v1.1.20~30 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=91e1e29d6dd92c5e707f05dcc9b2a376b0d8dfa1;p=oweals%2Fmusl.git fix pthread_create return value with PTHREAD_EXPLICIT_SCHED due to moved code, commit b8742f32602add243ee2ce74d804015463726899 inadvertently used the return value of __clone, rather than the return value of SYS_sched_setscheduler in the new thread, to check whether it needed to report failure. since a successful __clone returns the tid of the new thread, which is never zero, this caused pthread_create always to return with an invalid error number in the code path for PTHREAD_EXPLICIT_SCHED. this regression was not present in any releases. --- diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 2df2e9f9..27ace2c6 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -306,6 +306,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att if (do_sched) { __futexwait(&ssa.futex, -1, 1); + ret = ssa.futex; if (ret) return ret; }