Bug 78677 - __gthread_key_create assumed not to fail in eh_globals.cc
Summary: __gthread_key_create assumed not to fail in eh_globals.cc
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 6.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-05 06:55 UTC by Chris Johns
Modified: 2017-03-05 21:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-12-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Johns 2016-12-05 06:55:47 UTC
Some operating system, for example RTEMS, may fail to create a POSIX key if not configured with enough resources. The lack of any error reporting in __eh_globals_init::__eh_globals_init() means exceptions are silently switched from thread safe to not being thread safe and this is not a concern for RTEMS.

A way to report errors would be welcomed by RTEMS. We could hook this is a fatal error so the user is aware there is a critical issue that needs to be addressed.

Thanks
Chris
Comment 1 Jonathan Wakely 2016-12-05 10:29:25 UTC
(In reply to Chris Johns from comment #0)
> Some operating system, for example RTEMS, may fail to create a POSIX key if
> not configured with enough resources. The lack of any error reporting in
> __eh_globals_init::__eh_globals_init() means exceptions are silently
> switched from thread safe to not being thread safe and this is not a concern
> for RTEMS.

I assume this is a typo and you mean this *is* a concern for RTEMS? :-)

> A way to report errors would be welcomed by RTEMS. We could hook this is a
> fatal error so the user is aware there is a critical issue that needs to be
> addressed.

I agree there should be some code to deal with the error there.

This seems like a specific example of the broader problem you described in PR 60645.
Comment 2 Chris Johns 2016-12-06 00:52:21 UTC
(In reply to Jonathan Wakely from comment #1)
> (In reply to Chris Johns from comment #0)
> > Some operating system, for example RTEMS, may fail to create a POSIX key if
> > not configured with enough resources. The lack of any error reporting in
> > __eh_globals_init::__eh_globals_init() means exceptions are silently
> > switched from thread safe to not being thread safe and this is not a concern
> > for RTEMS.
> 
> I assume this is a typo and you mean this *is* a concern for RTEMS? :-)
> 

Yes, sorry about that.

> > A way to report errors would be welcomed by RTEMS. We could hook this is a
> > fatal error so the user is aware there is a critical issue that needs to be
> > addressed.
> 
> I agree there should be some code to deal with the error there.
> 
> This seems like a specific example of the broader problem you described in
> PR 60645.

It is similar and I think a more critical issue. Thread-safe exceptions is something users expect to be working if there is no error.

Reviewing the code a little more I am confused about the detail of how it works.

Is it reasonable to assume the static constructor needs to be called before any thread local exceptions are thrown?

We call constructors from the initial thread with the kernel up and running and user static constructors could start threads and these could raise exceptions.