https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67791
Jonathan Wakely changed:
What|Removed |Added
Summary|Crash using std::thread and |[8/9/10/11 Regression]
|iostream with dynamic |Crash using std::thread and
|loading of a shared library |iostream with dynamic
||loading of a shared library
Known to work||4.9.4
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Status|NEW |ASSIGNED
Known to fail||10.2.0, 11.0, 5.1.0, 8.4.0,
||9.3.0
Target Milestone|--- |8.5
--- Comment #8 from Jonathan Wakely ---
(In reply to Jonathan Wakely from comment #7)
> (In reply to nexyon from comment #4)
> > In any case std::thread should not
> > crash I guess, so just to fix that it would be necessary to check whether
> > the standard library was inizialized without threads.
>
> We used to check for the pthread_create weak symbol, and throw an exception
> instead of crashing. Since the fix for PR libstdc++/61841 we don't check it,
> and crash instead of throwing. That should be fixed.
Marking as a regression, because GCC 4.9 printed this error instead of
crashing:
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)
That's better than segfaulting with no explanation.
I incorrectly assumed that the use of _create added for PR 61841 would
make checking __gthread_active_p unnecessary. As the examples here show, that's
not true. The program calls __gthread_active_p() before main() runs, and at
that time libpthread.so is not loaded. When libpthread.so is loaded later, it's
too late for __gthread_active_p to notice.