Call _thread_init() from pthread_once() if it has not already been called.
This fixes a segfault in some C++ programs which use exceptions before main() has been called (i.e. from global constructors). Reviewed by: deischen
This commit is contained in:
parent
4e34488c31
commit
5c6b23bd7c
@ -39,6 +39,8 @@ int
|
||||
pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
|
||||
{
|
||||
if (once_control->state == PTHREAD_NEEDS_INIT) {
|
||||
if (_thread_initial == NULL)
|
||||
_thread_init();
|
||||
pthread_mutex_lock(&(once_control->mutex));
|
||||
if (once_control->state == PTHREAD_NEEDS_INIT) {
|
||||
init_routine();
|
||||
|
@ -39,6 +39,8 @@ int
|
||||
pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
|
||||
{
|
||||
if (once_control->state == PTHREAD_NEEDS_INIT) {
|
||||
if (_thread_initial == NULL)
|
||||
_thread_init();
|
||||
pthread_mutex_lock(&(once_control->mutex));
|
||||
if (once_control->state == PTHREAD_NEEDS_INIT) {
|
||||
init_routine();
|
||||
|
@ -39,6 +39,8 @@ int
|
||||
pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
|
||||
{
|
||||
if (once_control->state == PTHREAD_NEEDS_INIT) {
|
||||
if (_thread_initial == NULL)
|
||||
_thread_init();
|
||||
pthread_mutex_lock(&(once_control->mutex));
|
||||
if (once_control->state == PTHREAD_NEEDS_INIT) {
|
||||
init_routine();
|
||||
|
Loading…
Reference in New Issue
Block a user