libstdc++/2020: fstream initialization seg-faults if global locale is missing required facets
bumgard@roguewave.com
bumgard@roguewave.com
Sun Feb 18 16:06:00 GMT 2001
>Number: 2020
>Category: libstdc++
>Synopsis: fstream initialization seg-faults if global locale is missing required facets
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 18 16:06:02 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Gregory Bumgardner
>Release: gcc-3_0-branch
>Organization:
>Environment:
Red Hat Linux 2.2.16
>Description:
Creation of an fstream instance produces a segmentation
fault if the global locale does not contain a ctype facet
matching the template parameters of the filebuf
instantiation.
A bad_cast exception is thrown by a call to use_facet<>
in the basic_filebuf constructor, and this causes the
as yet, incomplete fstream instance to be destroyed.
The actual fault appears to occur because the ios_base
destructor calls ios_base::_M_call_callbacks before the
_M_callbacks field has been initialized. This happens
because basic_ios<>, as a virtual base class, is constructed
before basic_ostream's constructor has called its init()
method. This constructor is never executed because the
bad_cast exception is produced while constructing the
filebuf that would be supplied as its streambuf argument.
This problem might also exist for other stream types.
>How-To-Repeat:
Instantiate a basic_ofstream using a character type other
than char or wchar_t, and construct an instance of that
stream without changing the original global locale.
>Fix:
Not sure. May need to do go ahead and do
initialization in default constructor.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list