libstdc++ debugging, was:Re: Heads up: Several thousand g++ and libstdc++ test failures on sparc[64]

Pétur Runólfsson peturr02@ru.is
Thu Oct 9 14:40:00 GMT 2003


> > We now have two possibilities:
> > 1) _S_initialize_once is not called.
> > 2) _S_initialize_once is called, but it fails to initialize _S_global,
> > or _S_global is clobbered sometime after it is initialized.
> >
> > Can you find out which?
> 
> had a short time to try, as you see below, the once is never touched.

Thanks.

I have been digging through gcc-testresults, and two interesting things
have appeared.

1) The problem also shows up on i386-pc-solaris2.9
http://gcc.gnu.org/ml/gcc-testresults/2003-10/msg00348.html
so it's a Solaris problem, not a Sparc problem.

2) The testcases testsuite/thread/pthread*.cc are not failing.
This of course doesn't mean they are succeeding, but it's a strong
hint. These testcases contain:
// { dg-options "-D_GLIBCXX_ASSERT -pthreads" { target *-*-solaris* } }
so it seems that compiling with -pthreads fixes the problem.

My current theory is that __gthread_active_p() is for some reason
returning true when it should return false on Solaris. This should
be easy to check.

If this is the case, then there are two options for fixing the
bug.

1) Fix gthr on Solaris.

2) Change use of __gthread_active_p() and __gthread_once() from:

  void  
  locale::_S_initialize()
  {
#ifdef __GTHREADS
    if (__gthread_active_p())
      __gthread_once(&_S_once, _S_initialize_once);
    else
#endif
      {
        if (!_S_classic)
          _S_initialize_once();
      }
  }

to:

  void  
  locale::_S_initialize()
  {
#ifdef __GTHREADS
    if (__gthread_active_p())
      __gthread_once(&_S_once, _S_initialize_once);
#endif
      {
        if (!_S_classic)
          _S_initialize_once();
      }
  }

that is, the "else" is removed, everything else is as before.

So long as __gthread_active_p() always returns true when thread
support is enabled (and this seems to be the case since the
pthread*.cc test cases succeed), this should be threadsafe.

Regards,
Petur



More information about the Libstdc++ mailing list