This is the mail archive of the
mailing list for the libstdc++ project.
Re: sizeof() segfault and mutex initialization?
Benjamin Kosnik wrote:
I'll try :) Here's a small diff against CVS version of stl_alloc which
adds a malloc (sizeof ()) call to one of __pool_alloc's methods:
_S_thread_freelist_mutex = (__gthread_mutex_t*)malloc (sizeof
It's possible to do sizeof on structs defined inside the template class,
but not on for instance int or - what we really want to do -
__gthread_mutex_t. This seems to be the PR7112. Any work arounds?
Is __gthread_mutex_t a forward declaration or well defined at this point?
Does the size of __gthread_mutex_t change at any point? If not, do you
need to do this inside a templatized class?
7112 is fixed in mainline. If you are having problems, I suggest, as a
first step, posting a small, self-contained test case.
Again, think small.
RCS file: /cvsroot/gcc/gcc/libstdc++-v3/include/bits/stl_alloc.h,v
retrieving revision 1.31
diff -r1.31 stl_alloc.h
> void* foo;
> foo = malloc (sizeof (int));
Here's the "testapplication" used:
using namespace std;
This causes an internal compiler error: stl_alloc.h:425: internal
compiler error: Segmentation fault
For reference, the compiler used is:
Reading specs from
Configured with: ../gcc/configure --prefix=/root/projects/alloc/local
Thread model: posix
gcc version 3.4 20030202 (experimental)
What am I missing here?
Experience is what you get when you were expecting something else.