[libc-commits] [libc] [libc] EAGAIN and EWOULDBLOCK should be treated as success in futex wait (PR #203407)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Thu Jun 11 14:45:58 PDT 2026
https://github.com/SchrodingerZhu created https://github.com/llvm/llvm-project/pull/203407
The `futex` wait function means waiting until a real change has been detected. We should not reject valid EAGAIN/EWOULDBLOCK kernel detection as failures.
Pure human code.
>From b6ee81ac5ab28833dd043c1c3bc01b2fe9995e94 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yfzhu at google.com>
Date: Thu, 11 Jun 2026 14:45:24 -0700
Subject: [PATCH] [libc] EAGAIN and EWOULDBLOCK should be treated as success in
futex wait
The `futex` wait function means waiting until a real change has been detected. We should not reject valid EAGAIN/EWOULDBLOCK kernel detection as failures.
---
libc/src/__support/threads/linux/futex_utils.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libc/src/__support/threads/linux/futex_utils.h b/libc/src/__support/threads/linux/futex_utils.h
index ff6b5d526a3c1..61c1b7353e05b 100644
--- a/libc/src/__support/threads/linux/futex_utils.h
+++ b/libc/src/__support/threads/linux/futex_utils.h
@@ -66,6 +66,11 @@ class Futex : public cpp::Atomic<FutexWordType> {
if (ret == -EINTR)
continue;
+ // the value pointed to by uaddr was not equal to the expected
+ // value val at the time of the call (EAGAIN or EWOULDBLOCK).
+ if (ret == -EAGAIN || ret == -EWOULDBLOCK)
+ return 0;
+
if (ret < 0)
return cpp::unexpected(-ret);
return ret;
More information about the libc-commits
mailing list