https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100806

            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

Reply via email to