public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/115422] New: Multi-threaded condition_variable app throws when linking as -static on Linux
@ 2024-06-10 17:33 ilg at livius dot net
  2024-06-10 17:35 ` [Bug libstdc++/115422] " pinskia at gcc dot gnu.org
  2024-06-10 17:41 ` ilg at livius dot net
  0 siblings, 2 replies; 3+ messages in thread
From: ilg at livius dot net @ 2024-06-10 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115422
           Summary: Multi-threaded condition_variable app throws when
                    linking as -static on Linux
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ilg at livius dot net
  Target Milestone: ---

I have a test that checks C++ threads which synchronise via a
condition_variable.

The test runs fine on Linux/macOS/Windows, in various scenarios, except when I
build it as `-static` on Linux.

```
$ g++ sleepy-threads-cv.cpp -o sleepy-threads-cv -static -g -lpthread
$ ./static-sleepy-threads-cv 4
abcd
$ g++ sleepy-threads-cv.cpp -o static-sleepy-threads-cv -static -g -lpthread
$ ./static-sleepy-threads-cv 4
Segmentation fault
```

On some systems the result is an exception:

```
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
```

I encountered the issue while building the xPack GCC 14 binaries, but later
confirmed it on GCC 13 and older. 

The source code is attached.inside 

The problem seems to be the global condition variable and/or mutex; if I move
them inside the `spawnThreads()` function and pass pointers to them to all
threads, the test is functional even with `-static`.

Is there anything wrong with my test, or is this a small bug in libstdc++?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/115422] Multi-threaded condition_variable app throws when linking as -static on Linux
  2024-06-10 17:33 [Bug libstdc++/115422] New: Multi-threaded condition_variable app throws when linking as -static on Linux ilg at livius dot net
@ 2024-06-10 17:35 ` pinskia at gcc dot gnu.org
  2024-06-10 17:41 ` ilg at livius dot net
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-10 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

*** This bug has been marked as a duplicate of bug 115421 ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/115422] Multi-threaded condition_variable app throws when linking as -static on Linux
  2024-06-10 17:33 [Bug libstdc++/115422] New: Multi-threaded condition_variable app throws when linking as -static on Linux ilg at livius dot net
  2024-06-10 17:35 ` [Bug libstdc++/115422] " pinskia at gcc dot gnu.org
@ 2024-06-10 17:41 ` ilg at livius dot net
  1 sibling, 0 replies; 3+ messages in thread
From: ilg at livius dot net @ 2024-06-10 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

Liviu Ionescu <ilg at livius dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #2 from Liviu Ionescu <ilg at livius dot net> ---
Sorry for the noise, bugzilla asked to resubmit the attachment and entered the
duplicate.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-10 17:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 17:33 [Bug libstdc++/115422] New: Multi-threaded condition_variable app throws when linking as -static on Linux ilg at livius dot net
2024-06-10 17:35 ` [Bug libstdc++/115422] " pinskia at gcc dot gnu.org
2024-06-10 17:41 ` ilg at livius dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).