Opened 12 years ago

Closed 11 years ago

#664 closed Bugs (fixed)

crash in boost::spirit::parse

Reported by: nobody Owned by: Joel de Guzman
Milestone: Component: spirit
Version: None Severity: Problem
Keywords: Cc:


When using boost::spirit::parse() in a multithreaded
environment with
set the call to get_definition() in grammar.ipp can crash.

Here is the according code of grammar.ipp:

# ifdef BOOST_SPIRIT_THREADSAFE              // Line 224
        static boost::thread_specific_ptr<ptr_t>
        if (!tld_helper.get())
            tld_helper.reset(new ptr_t);
        ptr_t &helper = *tld_helper;
# else

When thread 1 enters Line 224 the static tld_helper
will be initialized by running the constructor.
If now thread 2 enters this code before thread 1 has
finished the contructor of tld_helper thread 2 will
call the get() method on the uninitialized tld_helper
what leads to an access violation in tss.cpp Line 108
due a nullpointer in tss_data.

Change History (4)

comment:1 Changed 12 years ago by Roland Schwarz

Logged In: YES 

Using a static object in a function is not safe under MT
conditions. Altough this applies to any satic objects, it is
not clear how this situation can be worked around in this
special case.
There is need for further research.

See also the thread:

comment:2 Changed 12 years ago by Roland Schwarz

Logged In: YES 

The ctor of boost::thread_specific_ptr must be protected
from concurrent access by multiple threads.
The most straightforward solution is to protect it by a
global mutex.

However I already proposed a potentially better solution. See:

comment:3 Changed 11 years ago by Daryle Walker

Component: Nonespirit
Severity: Problem

comment:4 Changed 11 years ago by Joel de Guzman

Resolution: Laterfixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.