abort/segfault in CVS main

Stefan Olsson stefan@xapa.se
Mon Feb 9 18:15:00 GMT 2004


Hi all,

well I have found what's causing the abort/segfault at least: __GTHREADS 
is not defined even though the compiler has posix support and I compile 
with -pthread flag.

I have no idea why this is happening. The gthr.h file somehow concludes 
that it should include gthr-single.h instead of the posix one...
...if i modify gthr.h to always include gthr-posix.h (instead of 
-single) it works like a charm!

Help?

Brgds

/Stefan

Stefan Olsson wrote:

> Forgot the compiler version:
> Reading specs from /home/admin/gcc/lib/gcc/i686-pc-linux-gnu/3.5.0/specs
> Configured with: ../cvs/gcc/configure --prefix=/home/admin/gcc 
> --enable-threads --enable-languages=c,c++
> Thread model: posix
> gcc version 3.5.0 20040206 (experimental)
>
> Brgds
>
> /Stefan
>
> Stefan Olsson wrote:
>
>> Hi,
>>
>> I might have a complete meltdown this late friday and miss the 
>> obvious, but after the recent changes to mt allocator (interface to 
>> allocate etc) my simple testapplication (see attached file) does not 
>> work anymore:
>> terminate called after throwing an instance of 'terminate called 
>> after throwing an instance of 'std::bad_alloc'
>> std::bad_alloc'
>>  what():  St9bad_alloc
>>  what():  St9bad_alloc
>> Aborted
>>
>> Sometimes it segfaults...
>> The original test program (that in a modified version now is part of 
>> the testsuite) runs just fine however.
>>
>> I have no idea why? Help? I have done a "cvs update" and a full "make 
>> bootstrap" just to be sure...
>>
>> Btw: The malloc_allocator also complains about missning declarations 
>> (for malloc and free) just like the version of mt_allocator currently 
>> in cvs. See patch in an earlier email from me today.
>>
>> Brgds
>>
>> /Stefan
>>
>> ------------------------------------------------------------------------
>>
>> #include <ext/mt_allocator.h>
>> #include <pthread.h>
>> #include <vector>
>>
>> void* Worker( void* arg )
>> {
>>  std::vector< std::vector< int, __gnu_cxx::__mt_alloc< int > >, 
>>               __gnu_cxx::__mt_alloc< std::vector< int,               
>> __gnu_cxx::__mt_alloc< int > > > > v1;
>>
>>  for( int i = 0; i < 10000; i++ )
>>    {
>>      std::vector< int, __gnu_cxx::__mt_alloc< int > > v2;
>>
>>      for( int j = 0; j < 32; j++ )
>>        {
>>          v2.push_back( 1 );
>>        }
>>
>>      v1.push_back( v2 );
>>    }
>>
>>  return NULL;
>> }
>>
>> int main()
>> {
>>  pthread_attr_t pthread_attr_default;
>>  pthread_attr_init( &pthread_attr_default );
>>
>>  int nowo = 32;
>>
>>  pthread_t *workers[ nowo ];
>>  for( int i = 0; i < nowo; i++ )
>>    {
>>      workers[ i ] = new pthread_t;
>>      pthread_create( workers[ i ], &pthread_attr_default, Worker, 
>> NULL );
>>    }
>>
>>  for( int i = 0; i < nowo; i++ )
>>    {
>>      pthread_join( *workers[ i ], NULL );
>>    }
>>
>>  return 0;
>> }
>>  
>>
>
>




More information about the Libstdc++ mailing list