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

Andreas Tobler toa@pop.agri.ch
Wed Oct 8 20:25:00 GMT 2003


Pétur Runólfsson wrote:


> 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?
> Does removing the #ifdef __GHTREADS block help? If it does, feel
> free to post a patch. It will make locale initialization
> non-threadsafe, but that's how things were before this mess anyway.

Pétur,

had a short time to try, as you see below, the once is never touched.
Well, I check again by tomorrow. But so far my tries. (Andreas's special 
debugging, get the routines, point to them in gdb with hex.)

I removed the #ifdef __GHTREADS (commented) and so on.

Thanks again!

Andreas

Continued:

locale::_S_initialize:

   void
   locale::_S_initialize_once()
   {
     // 2 references.
     // One reference for _S_classic, one for _S_global
     _S_classic = new (&c_locale_impl) _Impl(2);
     _S_global = _S_classic; 	
     new (&c_locale) locale(_S_classic);
   }

   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();
       }
   }


Find S_initialize in libstdc++.so.6, add the address to the offset from 
above:
  0xFF280000 + 6aaf8 = 0xff2eAAF80

Set breakpoint @ 0xff2eAAF8

Step through till crash :)

_ZNSt6locale13_S_initializeEv()
0xFF280000 + 0x6aaf8 = 0xff2eaaf8
(gdb) disass 0xff2eaaf8 0xff2eaaf8+16
Dump of assembler code from 0xff2eaaf8 to 0xff2eab08:
0xff2eaaf8:     save  %sp, -112, %sp
0xff2eaafc:     sethi  %hi(0x800), %g1
0xff2eab00:     sethi  %hi(0x55c00), %l7
0xff2eab04:     call  0xff2cb850
(gdb) disass 0xff2cb850 0xff2cb850+16
Dump of assembler code from 0xff2cb850 to 0xff2cb860:
0xff2cb850:     retl
0xff2cb854:     add  %o7, %l7, %l7
0xff2cb858:     retl
0xff2cb85c:     add  %o7, %l7, %l7

(gdb) b *0xff2eaaf8
Breakpoint 3 at 0xff2eaaf8
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: 
/opt/gcc/gcc-cvs/objdir/sparc-sun-solaris2.9/libstdc++-v3/header_cassert.exe 


Breakpoint 3, 0xff2eaaf8 in ?? () from /usr/local/lib/libstdc++.so.6

_ZNSt6locale5facet18_S_initialize_onceEv()
0xFF280000 + 0x6a718 = 0xff2ea718
(gdb) disass 0xff2ea718 0xff2ea718+20
Dump of assembler code from 0xff2ea718 to 0xff2ea72c:
0xff2ea718:     save  %sp, -112, %sp
0xff2ea71c:     sethi  %hi(0x400), %g1
0xff2ea720:     sethi  %hi(0x400), %i5
0xff2ea724:     sethi  %hi(0x56000), %l7
0xff2ea728:     call  0xff2cb850

(gdb) b *0xff2ea718
Breakpoint 1 at 0xff2ea718
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: 
/opt/gcc/gcc-cvs/objdir/sparc-sun-solaris2.9/libstdc++-v3/header_cassert.exe 


Program received signal SIGSEGV, Segmentation fault.
0xff2cc4c0 in ?? () from /usr/local/lib/libstdc++.so.6
(gdb)


_ZNSt6locale18_S_initialize_onceEv()
0xFF280000 + 0x6aa90 = 0xff2eaa90
(gdb) disass 0xff2eaa90 0xff2eaa90+20
Dump of assembler code from 0xff2eaa90 to 0xff2eaaa4:
0xff2eaa90:     save  %sp, -112, %sp
0xff2eaa94:     sethi  %hi(0x400), %g1
0xff2eaa98:     sethi  %hi(0x55c00), %l7
0xff2eaa9c:     call  0xff2cb850
0xff2eaaa0:
     add  %l7, 0x3e4, %l7        ! 0x55fe4 
<_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPwEEEEvv+23883>

(gdb) b *0xff2eaa90
Breakpoint 2 at 0xff2eaa90
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: 
/opt/gcc/gcc-cvs/objdir/sparc-sun-solaris2.9/libstdc++-v3/header_cassert.exe 


Program received signal SIGSEGV, Segmentation fault.
0xff2cc4c0 in ?? () from /usr/local/lib/libstdc++.so.6
(gdb)




More information about the Libstdc++ mailing list