Opened 16 years ago

Closed 16 years ago

Last modified 16 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:

Description

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 by lsh123, 16 years ago

Logged In: YES 
user_id=851494

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 by John Maddock, 16 years ago

Logged In: YES 
user_id=14804

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.

John.

comment:3 by John Maddock, 16 years ago

Status: assignedclosed
Logged In: YES 
user_id=14804

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 by lsh123, 16 years ago

Logged In: YES 
user_id=851494

Thanks!!!
Note: See TracTickets for help on using tickets.