Overview
Features
Download
Documentation
Community
Add-Ons & Services

Is Poco::format thread-safe?

A general discussion forum.

Is Poco::format thread-safe?

Postby dpa » 11 Aug 2013, 21:55

Hello,

the function Poco::format(...) is defined in Foundation/src/Format.cpp, and it calls formatOne() from the same file. In turn, formatOne() calls std::locale::classic() , when the Poco libraries are compiled without defining POCO_NO_LOCALE . Calling later Poco::format () from different threads leads to not synchronized access to std::locale from that threads.

The documentation of Poco::format () at http://pocoproject.org/docs/Poco.html does not mention these details. Please amend the later to indicate, that when the libraries are compiled without #define POCO_NO_LOCALE, the function Poco::format() is not thread-safe.

Regards
Dilyan Palauzov
dpa
 
Posts: 6
Joined: 11 Aug 2013, 21:40

Re: Is Poco::format thread-safe?

Postby guenter » 12 Aug 2013, 12:57

I'm would really surprise me if std::locale::classic() would not be thread safe on all major platforms.
guenter
 
Posts: 1107
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Is Poco::format thread-safe?

Postby dpa » 15 Aug 2013, 00:28

I have found the problem, while I was running Poco with libstdc++ from gcc473 over valgrind/helgrind. The inconsistency comes from the file
gcc-4.7.3/libstdc++-v3/src/c++98/locale.cc, line 87

// This is used to initialize global and classic locales, and
// assumes that the _Impl objects are constructed correctly.
// The lack of a reference increment is intentional.
locale::locale(_Impl* __ip) throw() : _M_impl(__ip)
{ }

to be exact in "_M_impl(__ip)" . Somehow two threads try to set the same _M_impl here without synchronizing each other.
dpa
 
Posts: 6
Joined: 11 Aug 2013, 21:40


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests