From 4fd58e839585b6a97fb3c45886cd8f0c4a368706 Mon Sep 17 00:00:00 2001 From: Adrian Pistol Date: Thu, 4 Oct 2018 14:25:29 +0200 Subject: [PATCH] musl: update to 1.1.20. --- srcpkgs/musl/patches/fix-race-condition.patch | 54 +++++++++++++++++++ srcpkgs/musl/template | 4 +- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/musl/patches/fix-race-condition.patch diff --git a/srcpkgs/musl/patches/fix-race-condition.patch b/srcpkgs/musl/patches/fix-race-condition.patch new file mode 100644 index 00000000000..04a71fde32b --- /dev/null +++ b/srcpkgs/musl/patches/fix-race-condition.patch @@ -0,0 +1,54 @@ +From 0db393d3a77bb9f300a356c6a5484fc2dddb161d Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen +Date: Tue, 18 Sep 2018 10:03:27 +0300 +Subject: fix race condition in file locking + +The condition occurs when +- thread #1 is holding the lock +- thread #2 is waiting for it on __futexwait +- thread #1 is about to release the lock and performs a_swap +- thread #3 enters the __lockfile function and manages to grab the lock + before thread #1 calls __wake, resetting the MAYBE_WAITERS flag +- thread #1 calls __wake +- thread #2 wakes up but goes again to __futexwait as the lock is + held by thread #3 +- thread #3 releases the lock but does not call __wake as the + MAYBE_WAITERS flag is not set + +This condition results in thread #2 not being woken up. This patch fixes +the problem by making the woken up thread ensure that the flag is +properly set before going to sleep again. + +Mainainer's note: This fixes a regression introduced in commit +c21f750727515602a9e84f2a190ee8a0a2aeb2a1. +--- + src/stdio/__lockfile.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git src/stdio/__lockfile.c.orig src/stdio/__lockfile.c +index 2ff75d8a..0dcb2a42 100644 +--- src/stdio/__lockfile.c.orig ++++ src/stdio/__lockfile.c +@@ -8,13 +8,13 @@ int __lockfile(FILE *f) + int owner = f->lock, tid = __pthread_self()->tid; + if ((owner & ~MAYBE_WAITERS) == tid) + return 0; +- for (;;) { +- owner = a_cas(&f->lock, 0, tid); +- if (!owner) return 1; +- if (a_cas(&f->lock, owner, owner|MAYBE_WAITERS)==owner) break; ++ owner = a_cas(&f->lock, 0, tid); ++ if (!owner) return 1; ++ while ((owner = a_cas(&f->lock, 0, tid|MAYBE_WAITERS))) { ++ if ((owner & MAYBE_WAITERS) || ++ a_cas(&f->lock, owner, owner|MAYBE_WAITERS)==owner) ++ __futexwait(&f->lock, owner|MAYBE_WAITERS, 1); + } +- while ((owner = a_cas(&f->lock, 0, tid|MAYBE_WAITERS))) +- __futexwait(&f->lock, owner, 1); + return 1; + } + +-- +cgit v1.2.1 + diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template index 34fa0bf75c6..096aa12bcca 100644 --- a/srcpkgs/musl/template +++ b/srcpkgs/musl/template @@ -1,6 +1,6 @@ # Template file for 'musl'. pkgname=musl -version=1.1.19 +version=1.1.20 revision=1 build_style=gnu-configure configure_args="--prefix=/usr --disable-gcc-wrapper" @@ -11,7 +11,7 @@ maintainer="Juan RP " license="MIT" homepage="http://www.musl-libc.org/" distfiles="http://www.musl-libc.org/releases/musl-${version}.tar.gz" -checksum=db59a8578226b98373f5b27e61f0dd29ad2456f4aa9cec587ba8c24508e4c1d9 +checksum=44be8771d0e6c6b5f82dd15662eb2957c9a3173a19a8b49966ac0542bbd40d61 nostrip_files="libc.so" shlib_provides="libc.so"