Boost logo

Boost Users :

Subject: [Boost-users] [xpressive] sporadic crashes in multi-threaded code
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2012-01-12 09:29:00


Hello *,

I face some issue with sporadic crashes in xpressive which I think a result
of a race condition. The use case is:

a function which needs to parse smth create local regex objects:

  const sregex any_char = _;
  sregex const& rdelim = parser_->delimiter(); //some dynamic delimiter
token

  const sregex re_prefix
    = bos
>> (s1=-*by_ref(any_char))
>> *(s2=by_ref(rdelim))
>> eos
  ;

calling this function from multiple threads results in a crash with (boost
1.42, gcc 4.3.5 on debian linux). I previously had more crashes, but moved
all
regex objects to global space as const objects and they seem to be fine
now. This is the only place I left with a local regex.

In the stack trace it seems like internals of the local object regex are
freed via boost weak_ptr with possible double delete attempt.

The stack-trace of the created core-dump during the crash can be accessed
via:
https://docs.google.com/open?id=0BzJl1eEH-CCGODU5N2JhOTAtNWMxMy00OGNhLThhNzctNWQ4OWJlOGFkOTdk
(Did not want to send addional 200k to the mailing list.)

Many thanks for help,
Ovanes



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