Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#692 closed Bugs (Fixed)

cpp_regex_traits<charT>::toi() method fails in the MT case

Reported by: lsh123 Owned by: nobody
Milestone: Component: None
Version: None Severity:
Keywords: Cc:


cpp_regex_traits<charT>::toi() method fails to parse
the string correctly when it is used in multi-threaded
environment. Originally, I run into this problem in
regex parser code and traced it down to
cpp_regex_traits<charT>::toi() method (btw, this
happens on Linux only, Windows code goes thru a
different code path). 

I believe that the problem is caused by the fact that
*buffered* m_pimpl->m_sbuf and m_pimpl->m_is are used
inside cpp_regex_traits<charT>::toi() method without
locking. Thus, if two threads are trying to use it in
the same time, it fails.

Change History (4)

comment:1 Changed 12 years ago by lsh123

Logged In: YES 

The attached patch replace cpp_regex_traits<charT>::toi()
implementation with w32_regex_traits<charT>::toi() code.
This completely solves the multithreading problem.

comment:2 Changed 12 years ago by John Maddock

Logged In: YES 

Confirmed, I'm working on a fix, and updated test cases. 

You can also fix this by defining BOOST_REGEX_USE_C_LOCALE
in boost/regex/user.hpp and rebuilding everything.


comment:3 Changed 12 years ago by John Maddock

Status: assignedclosed
Logged In: YES 

OK, I've been able to update the regression test suite so it
reproduces the problem, and added the patch attached as a
fix for this, and to generally tighten up const-correctness.

Thanks for the report, John.

comment:4 Changed 12 years ago by lsh123

Logged In: YES 

Note: See TracTickets for help on using tickets.