This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: libstdc++ multi-threading: std::vector resize crash
- From: Pavel Emeliyanenko <asm at mpi-sb dot mpg dot de>
- To: libstdc++ at gcc dot gnu dot org
- Date: Fri, 20 Apr 2007 15:13:38 +0200
- Subject: Re: libstdc++ multi-threading: std::vector resize crash
- Reply-to: Pavel Emeliyanenko <asm at mpi-sb dot mpg dot de>
Hi all,
I have successfully investigated the bug. And it surprisingly has
nothing to deal with libstdc++. So, I should apologize for blaming libstdc++ :)
As turned out, this problem is related to "multi-threaded
programming with CORE and Gmp libraries".
Probably it is not the right place for such a discussion.
Nevertheless, I would like to discuss it here to make sure somebody
else will not fall into the same trap..
Unfortunately, CORE library (http://cs.nyu.edu/exact/core) is quite
poor documented and I didn't find in official sources any note that it
implicitly uses it's own memory pool (CORE::MemoryPool<T>). The memory
pool is installed by replacing "operator new" using macro definitions.
So, if this feature is turned on, the library is not thread-safe.
Moreover, the actual segfault occurs not in the CORE library but in
the underlying Gmp's mem-alloc function, such that it is hard to
investigate it.
To work-around this bug one needs to disable CORE's memory pool.
This is done by recompiling the library with CORE_DISABLE_MEMORY_POOL
flag defined either in CORE/Impl.h or as a compiler option.
(of course, one assumes that gmp library was properly configured with
--enable-alloca=malloc-reentrant option and so is libstdc++).
> I have the problem with libstdc++ memory allocation which I'm fighting against
> the last 2 weeks. Before writing directly to mailing list I tried to
> more or less thoroughly read through existent messages however this
> didn't help me a lot.
> The problem is the following: I work in EXACUS project and my server
> program should process multiple requests from clients (CGI-scripts)
> simultaneously. Without getting deeper into details, I pasted a piece
> of code where it crashes.
--
Best regards,
Pavel mailto:asm@mpi-sb.mpg.de