Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-01-26 15:14:36


Leon Mergen wrote:
> Hello,
>
> I am sorry if this is a stupid question, or simply inappropriatie for
> this list. I am currently camping with this bug for way too long, so I
> decided to ask this mailinglist.
>
> I am currently in the process of finding out where a segfault is, and
> how to fix it. Now, I am using the boost regex library to parse my
> regexes, and for some reason when multiple threads use this regex
> library, it seems to mess up and generate segfaults (it works perfectly
> with only one thread). Since it also doesn't always occur on the same
> place, and doesn't even occur /all/ the times, I have a strong feeling
> this has something to do with thread safety.
>
> On the Boost website is was able to find out that the boost regex
> library should be thread safe when BOOST_HAS_THREADS is defined; I've
> tested this, and this worked.
> ( http://www.boost.org/libs/regex/doc/thread_safety.html )
>
> However, I also was able to find a mailinglist message that provides
> some instructions on how to make certain boost regex functions
> thread-safe :
> ( http://lists.boost.org/MailArchives/boost/msg59110.php )
<snip>

That is not specifically about thread-safety in Boost.Regex; the
initialisation of local static variables is generally not done in a
thread-safe way even by implementations that are intended to support
multithreaded programs, and this goes for variables of any type.

I can tell you for certain, though, that std::string is not thread-safe
in libstdc++ (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10350>).
  That might be the source of the problem.

Ben.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net