sizeof() segfault and mutex initialization?

Stefan Olsson stefan@snon.net
Wed Feb 19 12:34:00 GMT 2003


Hi!

During the rewrite of our allocator into a patch for stl_alloc.h we have 
encountered two problems.

1) Compiler segfaults with

--snip--
snon:~/projects/alloc/source# /root/projects/alloc/local/bin/g++ 
alloc_perf_comp_single.cc -static -pthread
In file included from /root/projects/alloc/local/include/c++/3.4/vector:68,
                 from alloc_perf_comp_single.cc:28:
/root/projects/alloc/local/include/c++/3.4/bits/stl_alloc.h: In static 
member
   function `static void std::__mt_alloc<__inst>::_S_init()':
/root/projects/alloc/local/include/c++/3.4/bits/stl_alloc.h:287: 
internal compiler error: Segmentation
   fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
--snip--

when doing a sizeof inside a template method:

_S_thread_freelist_mutex = (__gthread_mutex_t*)malloc (sizeof 
(__gthread_mutex_t));

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?


2) gthr does not implement a __gthread_mutex_init () function, only a 
static initializer. However we need to create 1-n mutexes - one per bin 
- during initialization code. How can this be done? Is it possible/ok to 
call __gthread_objc_mutex_allocate?

Brgds

/Stefan

-- 
Experience is what you get when you were expecting something else.




More information about the Libstdc++ mailing list