From e50768d0a11b6b109aaa8cde3ee7afde25fa8726 Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 29 May 2024 18:50:59 -0300 Subject: [PATCH] mlibc: temp patch while fix isn't upstream --- patches/mlibc/jinx-working-patch.patch | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index d4bbf28d..66aeaff0 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -75,6 +75,20 @@ index 3474615..e034881 100644 } char **backtrace_symbols(void *const *, int) { +diff --git mlibc-clean/options/internal/include/mlibc/lock.hpp mlibc-workdir/options/internal/include/mlibc/lock.hpp +index aa05079..8bff987 100644 +--- mlibc-clean/options/internal/include/mlibc/lock.hpp ++++ mlibc-workdir/options/internal/include/mlibc/lock.hpp +@@ -50,7 +50,8 @@ struct FutexLockImpl { + + // If the wait returns EAGAIN, that means that the waitersBit was just unset by + // some other thread. In this case, we should loop back around. +- if (e && e != EAGAIN) ++ // Also loop around in case of a signal interrupting the wait ++ if (e && e != EAGAIN && e != EINTR) + mlibc::panicLogger() << "sys_futex_wait() failed with error code " << e << frg::endlog; + + // Opportunistically try to take the lock after we wake up. diff --git mlibc-clean/options/posix/generic/dlfcn-stubs.cpp mlibc-workdir/options/posix/generic/dlfcn-stubs.cpp index fc34a3b..b1a95a9 100644 --- mlibc-clean/options/posix/generic/dlfcn-stubs.cpp @@ -85,6 +99,22 @@ index fc34a3b..b1a95a9 100644 #include #include +diff --git mlibc-clean/options/posix/generic/pthread-stubs.cpp mlibc-workdir/options/posix/generic/pthread-stubs.cpp +index 775989b..d28f950 100644 +--- mlibc-clean/options/posix/generic/pthread-stubs.cpp ++++ mlibc-workdir/options/posix/generic/pthread-stubs.cpp +@@ -844,7 +844,10 @@ int pthread_once(pthread_once_t *once, void (*function) (void)) { + }else{ + // a different thread is currently running the initializer. + __ensure(expected == onceLocked); +- if(int e = mlibc::sys_futex_wait((int *)&once->__mlibc_done, onceLocked, nullptr); e) ++ // if it gets interrupted by a signal, check again. ++ // EAGAIN will also be a retry, as it means the other thread completed ++ // and changed the __mlibc_done variable to signal it ++ if(int e = mlibc::sys_futex_wait((int *)&once->__mlibc_done, onceLocked, nullptr); e && e != EINTR && e != EAGAIN) + __ensure(!"sys_futex_wait() failed"); + expected = __atomic_load_n(&once->__mlibc_done, __ATOMIC_ACQUIRE); + } diff --git mlibc-clean/options/posix/generic/unistd-stubs.cpp mlibc-workdir/options/posix/generic/unistd-stubs.cpp index 3279cc6..71837aa 100644 --- mlibc-clean/options/posix/generic/unistd-stubs.cpp