From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 22129398B413; Thu, 27 May 2021 21:21:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22129398B413 From: "gatroubo at squizzy dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100806] New: deadlock in std::counting_semaphore Date: Thu, 27 May 2021 21:21:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gatroubo at squizzy dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2021 21:21:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100806 Bug ID: 100806 Summary: deadlock in std::counting_semaphore Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gatroubo at squizzy dot net Target Milestone: --- Hi, there seems to be some sort of deadlock in std::counting_semaphore. In the following test program, I create 10 threads, each thread tries to acquire a semaphore (initial value 4), waits 100ms, and then releases the semaphore: https://wandbox.org/permlink/Zt3d4EC5vNOXtr9W Most of the time, the program seems to be in a deadlock after 5 threads acquired/released the semaphore. When I compile and run the same code with clang 11.1 I get the expected behavoir (all 10 threads aquire/release the semaphore and the program exits successfully): https://wandbox.org/permlink/XjQaoyy9C6uiDYlo Thanks for your effort to create such a great tool! -Tobias=