HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/src/glibc/debian/patches/ubuntu/submitted-broadcast-to-prevent-deadlock.diff
Description: Signal all waiters to prevent a potential deadlock

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25847
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1899800
Author: Qin Li <qin.li@thetradedesk.com>

diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
index cf372bc017..88ac0be6e1 100644
--- a/nptl/pthread_cond_wait.c
+++ b/nptl/pthread_cond_wait.c
@@ -608,6 +608,15 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex,
 		     the signal from, which cause it to block using the
 		     futex).  */
 		  futex_wake (cond->__data.__g_signals + g, 1, private);
+
+		  /* We might be wrong about stealing, we got the signal
+		     from the an old g1, but ended up returning it to
+		     a different g1. We can't tell whether it is the case.
+		     If it is, we now caused another issue:
+		     now g_refs[g1] is one less than g_size[g1].
+		     The mitigation step is to broadcast g1 and g2, let every
+		     waiter wake up spuriosly. */
+		  __pthread_cond_broadcast(cond);
 		  break;
 		}
 	      /* TODO Back off.  */