Modify

Opened 11 years ago

Closed 10 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:

Description

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

Here is the according code of grammar.ipp:

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

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.

Attachments (0)

Change History (4)

comment:1 Changed 11 years ago by Roland Schwarz

Logged In: YES 
user_id=541730

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:
http://lists.boost.org/Archives/boost/2006/04/102794.php

comment:2 Changed 11 years ago by Roland Schwarz

Logged In: YES 
user_id=541730

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:
http://lists.boost.org/Archives/boost/2006/10/111221.php

comment:3 Changed 10 years ago by Daryle Walker

Component: Nonespirit
Severity: Problem

comment:4 Changed 10 years ago by Joel de Guzman

Resolution: Laterfixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Joel de Guzman.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.