Return-Path: X-Original-To: apmail-stdcxx-issues-archive@minotaur.apache.org Delivered-To: apmail-stdcxx-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 011779E99 for ; Mon, 6 Feb 2012 21:21:24 +0000 (UTC) Received: (qmail 21692 invoked by uid 500); 6 Feb 2012 21:21:23 -0000 Delivered-To: apmail-stdcxx-issues-archive@stdcxx.apache.org Received: (qmail 21346 invoked by uid 500); 6 Feb 2012 21:21:23 -0000 Mailing-List: contact issues-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list issues@stdcxx.apache.org Received: (qmail 21222 invoked by uid 99); 6 Feb 2012 21:21:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2012 21:21:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2012 21:21:20 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 7F269CC398 for ; Mon, 6 Feb 2012 21:20:59 +0000 (UTC) Date: Mon, 6 Feb 2012 21:20:59 +0000 (UTC) From: "Martin Sebor (Commented) (JIRA)" To: issues@stdcxx.apache.org Message-ID: <231474026.3760.1328563259522.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1798540128.12171.1328401554492.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (STDCXX-1056) std::moneypunct and std::numpunct implementations are not thread-safe MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-1056?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201603#comment-13201603 ] Martin Sebor commented on STDCXX-1056: -------------------------------------- I think the problem in STDCXX-839 is that the tests run too long, not that they deadlock or suffer from some other kind of data race. The {{std::numpunct}} inline members were designed to be as small and as efficient as possible to minimize code bloat and maximize iostream performance. Adding locks to them would very likely defeat both of these goals. If we do need additional locking it should do in one of the out-of-line implementation functions (I think {{\_\_rw::__rw_get_punct()}} is one such function). In any case, before we change anything in this area we need a test case to see what's broken first, and we should also put together one that verifies that what we change doesn't adversely affect performance. > std::moneypunct and std::numpunct implementations are not thread-safe > --------------------------------------------------------------------- > > Key: STDCXX-1056 > URL: https://issues.apache.org/jira/browse/STDCXX-1056 > Project: C++ Standard Library > Issue Type: Bug > Components: 22. Localization > Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0 > Environment: Solaris 10 and 11, RedHat and OpenSuSE Linux, Sun C++ Compilers 12.1, 12.2, 12.3 > Issue is independent of platform and/or compiler. > Reporter: Stefan Teleman > Labels: thread-safety > Fix For: 4.2.x, 4.3.x, 5.0.0 > > Attachments: stdcxx-1056.patch > > > several member functions in std::moneypunct<> and std::numpunct<> return > a std::string by value (as required by the Standard). The implication of return-by-value > being that the caller "owns" the returned object. > In the stdcxx implementation, the std::basic_string copy constructor uses a shared > underlying buffer implementation. This shared buffer creates the first problem for > these classes: although the std::string object returned by value *appears* to be owned > by the caller, it is, in fact, not. > In a mult-threaded environment, this underlying shared buffer can be subsequently modified by a different thread than the one who made the initial call. Furthermore, two or more different threads can access the same shared buffer at the same time, and modify it, resulting in undefined run-time behavior. > The cure for this defect has two parts: > 1. the member functions in question must truly return a copy by avoiding a call to the copy constructor, and using a constructor which creates a deep copy of the std::string. > 2. access to these member functions must be serialized, in order to guarantee atomicity > of the creation of the std::string being returned by value. > Patch for 4.2.1 to follow. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira