[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libstc++2.10-dev & threads



On Tue, Jul 11, 2000 at 11:06:52AM +0200, Wichert Akkerman wrote:
> Previously Chris Leishman wrote:
> > I've just started doing a little coding in c++ using threads - and I've
> > quickly come to realise that the version of the STL in libstdc++2.10-dev
> > is _not_ thread safe.
> 
> Can you be a bit more specific? I'm doing some multi-threaded STL
> stuff myself and would be very interested in seeing what you problems
> are.
> 
> Wichert.
> 


Sure.... try writing any code that uses class string (actually basic_string).

I found that even using string objects created on the stack (thus thread
specific) was still a problem, and I was getting SEGV deep down in the string
allocator (where two threads where simultaneously calling free()).

It looks like the version of STL distributed with the latest gcc (which is
whats in libstdc++2.10-dev) has a section for the "GNU ANSI C++ Library".
These headers are in "/usr/include/g++-3/std/".  These headers define an
implementation of basic_string <std/bastring.h> that is used instead of the
version supplied by SGI.

This implementation seems to have all sorts of non-thread safe nasties in 
it, eg:

void release () { if (--ref == 0) delete this; }

(although this was not the cause of the majority of problems I found).


Note that most of the other STL headers appear to be from the SGI
implementation (though I haven't compared them to determine which version).


Regards,

Chris

-- 
----------------------------------------------------------------------
            Linux, because I'd like to *get there* today
----------------------------------------------------------------------
Reply with subject 'request key' for GPG public key.  KeyID 0xB4E24219

Attachment: pgpQlzkL4iQTg.pgp
Description: PGP signature


Reply to: