From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29056 invoked by alias); 3 Apr 2003 14:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 29044 invoked by uid 71); 3 Apr 2003 14:46:01 -0000 Date: Thu, 03 Apr 2003 14:46:00 -0000 Message-ID: <20030403144601.29043.qmail@sources.redhat.com> To: jlquinn@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Jerry Quinn Subject: Re: libstdc++/9828: Regression: Segmentation fault in num_put::put Reply-To: Jerry Quinn X-SW-Source: 2003-04/txt/msg00089.txt.bz2 List-Id: The following reply was made to PR libstdc++/9828; it has been noted by GNATS. From: Jerry Quinn To: paolo@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, peturr02@ru.is, gcc-gnats@gcc.gnu.org Cc: libstdc++@gcc.gnu.org Subject: Re: libstdc++/9828: Regression: Segmentation fault in num_put::put Date: Thu, 03 Apr 2003 09:41:47 -0500 paolo@gcc.gnu.org writes: > Synopsis: Regression: Segmentation fault in num_put::put > > Responsible-Changed-From-To: unassigned->jlquinn > Responsible-Changed-By: paolo > Responsible-Changed-When: Mon Mar 24 13:16:11 2003 > Responsible-Changed-Why: > Jerry, I'm tentatively assigning this one to you: the problem > appear in your new _M_convert_int and _M_group_int. > State-Changed-From-To: open->analyzed > State-Changed-By: paolo > State-Changed-When: Mon Mar 24 13:16:11 2003 > State-Changed-Why: > Confirmed 3.3 and 3.4. > > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9828 OK, I can see why the crash is happening now. In the test program, we have: typedef num_put npw_t; wostringstream stream; const npw_t& npw = use_facet(stream.getloc()); npw.put(stream, cout, L' ', static_cast(10)); In particular, we're calling num_put::put with basic_ostream. The printing code pulls the locale_cache from the ios_base that is provided - in this case, cout. But the code assumes that the cache provided by ios_base is instantiated with the same type as the num_put class, and hence that the ios_base is a base class for an ostream that was also instantiated with that type. In this failure, cout provides __locale_cache, but we interpret it as __locale_cache and things go downhill from there. This is ugly! To make this work, we need to get __locale_cache from somewhere, in sync with the facet being used for printing. I'm open to suggestions here. As is, we're trading one regression for another - and the performance regression without the locale cache stuff is pretty bad. One possibility is that ios_base would have to be able to provide a cache for any type that is asked for - seems ugly. Another is that locales carry the cache info to avoid this problem. Or perhaps the facets cache the info required, but that may get into overlaps of info between facets. Jerry Quinn