This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

abort/segfault in CVS main


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]