Bug 1243366

Summary: Wrong behaviour of basic_streambuf symbols defined in libstdc++.so
Product: Red Hat Enterprise Linux 7 Reporter: Jonathan Wakely <jwakely>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Miroslav Franc <mfranc>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: mcermak, mfranc, mpolacek, ohudlick
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-4.8.5-4.el7 Doc Type: Bug Fix
Doc Text:
No description necessary
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 12:23:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to fix streambuf copies in gcc-4.8
none
Patch to fix streambuf copies in gcc-4.4 none

Description Jonathan Wakely 2015-07-15 10:07:33 UTC
Libstdc++ exports the following symbols:

_ZNSt15basic_streambufIcSt11char_traitsIcEEC1ERKS2_@@GLIBCXX_3.4
_ZNSt15basic_streambufIcSt11char_traitsIcEEC2ERKS2_@@GLIBCXX_3.4
_ZNSt15basic_streambufIcSt11char_traitsIcEEaSERKS2_@@GLIBCXX_3.4
_ZNSt15basic_streambufIwSt11char_traitsIwEEC1ERKS2_@@GLIBCXX_3.4
_ZNSt15basic_streambufIwSt11char_traitsIwEEC2ERKS2_@@GLIBCXX_3.4
_ZNSt15basic_streambufIwSt11char_traitsIwEEaSERKS2_@@GLIBCXX_3.4

These are the copy constructor and copy assignment operator for std::streambuf and std::wstreambuf. Although those functions are defined they don't have sensible definitions e.g. the assignment operator doesn't update any members:

      __streambuf_type&
      operator=(const __streambuf_type&) { return *this; };

Prior to gcc-5 those functions are 'private' and are never used, so the symbols are redundant, and it's not a problem that the functions have the wrong semantics (in retrospect it would have been better to declare them private but not define them at all, so the symbols would not have been in libstdc++.so).

In C++11 basic_streambuf is copyable, so when using gcc-5 from DTS-4 code might require the copy constructor and assignment operator. However, that code will find the exported symbols in the system libstdc++.so, and those symbols don't have sensible definitions.

By applying a patch to the RHEL system GCC we can ensure that the symbols defined in the library have the correct semantics for C++11 code built with DTS-4. That change would have no impact on code built with the system compiler or DTS-3, because such code never uses those symbols anyway.

Changing the definition of these symbols would fix these failing tests when using devtoolset:

27_io/basic_fstream/assign/1.cc execution test
27_io/basic_ifstream/assign/1.cc execution test
27_io/basic_istringstream/assign/1.cc execution test
27_io/basic_istringstream/cons/move.cc execution test
27_io/basic_ofstream/assign/1.cc execution test
27_io/basic_ostringstream/assign/1.cc execution test
27_io/basic_streambuf/cons/57394.cc execution test
27_io/basic_stringstream/assign/1.cc execution test

Comment 3 Jonathan Wakely 2015-07-15 14:59:17 UTC
Created attachment 1052377 [details]
Patch to fix streambuf copies in gcc-4.8

Comment 4 Jonathan Wakely 2015-07-15 15:00:11 UTC
Created attachment 1052378 [details]
Patch to fix streambuf copies in gcc-4.4

Comment 8 errata-xmlrpc 2015-11-19 12:23:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2080.html