From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 030D73858404; Wed, 3 May 2023 03:04:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 030D73858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683083044; bh=4kfzWZhlZ6+CG/TGoQ+mjGm/PWZmT/E2xEmEFb7qTiE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Tq12S8I6Pa5wl2SG96VXAeWnCEFjmHSo7t+xOP8CQUAdCmvny+z11QhIL12BEJaA8 jpO3OjxWxKjZDvMsRYboS20hyJh+lLZ1ZRsL/gqLGWfE/ViCMZ2dsHmW5D4cq/ZIYy yMipb3jX9n33i6wpw80Dwmc0xmU/dpqRnINyik1o= From: "malteskarupke at fastmail dot fm" To: glibc-bugs@sourceware.org Subject: [Bug nptl/25847] pthread_cond_signal failed to wake up pthread_cond_wait due to a bug in undoing stealing Date: Wed, 03 May 2023 03:04:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nptl X-Bugzilla-Version: 2.27 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: malteskarupke at fastmail dot fm X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: carlos at redhat dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D25847 --- Comment #56 from Malte Skarupke --- Thanks for the review. Two points: 1. I agree that this one is wrong. I'll fix it. 2. It did strike me as odd that all the stores to g_signals are with relaxed MO. So if there is no group switching, pthread_cond_wait doesn't actually synchronize with pthread_cond_signal. I understand that the reason is that condition variables are always used together with a mutex, and the mutex fo= rces synchronization, but even knowing that, it's kinda weird. I'm not sure about the subtleties about how CPUs behave without acquire-rel= ease semantics. What happens if someone signals without a mutex? What state does= the woken thread see? This sounds like you could get really weird bugs if it se= es partial state. I know it's wrong to signal without locking/unlocking the mutex, but I woul= dn't be 100% confident that there are no valid cases where you'd do that. Like s= ome kind of job system where you signal a bunch and have a broadcast at the end= to make sure everyone gets woken. Since I had a hard time reasoning about this, I had a half-finished tenth p= atch in the series where I changed this and just made all stores to g_signals use release MO, just to remove the hard-to-reason-about case. Would you be interested in that patch? --=20 You are receiving this mail because: You are on the CC list for the bug.=