public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: theonetruekenny@yahoo.com
To: gcc-gnats@gcc.gnu.org
Cc: kenny.simpson@gs.com
Subject: libstdc++/3045: global stream objects destructor semantics
Date: Mon, 04 Jun 2001 01:26:00 -0000	[thread overview]
Message-ID: <20010604082334.25473.qmail@sourceware.cygnus.com> (raw)

>Number:         3045
>Category:       libstdc++
>Synopsis:       global stream objects destructor semantics
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 04 01:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     theonetruekenny@yahoo.com
>Release:        cvs 20010603
>Organization:
>Environment:
source
>Description:
In libstdc++-v3/src/ios.cc, function ios_base::Init::_S_ios_destroy are these lines:
	delete cout.rdbuf();
	delete cin.rdbuf();
	delete cerr.rdbuf();

These are no doubt the counterpart to the following lines from ios_base::Init::_S_ios_create:
	new (&cout) ostream(new filebuf(stdout, ios_base::out, __bufsize));
	new (&cin) istream(new filebuf(stdin, ios_base::in, 1));
	new (&cerr) ostream(new filebuf(stderr, ios_base::out, __bufsize));

However, the use of the rdbuf() method is incorrect. (See previous bug report dealing with rdbuf()).  This use of rdbuf() could lead to badness if cout/cin/cerr/clog were to be redirected.
>How-To-Repeat:
#include <fstream>
#include <iostream>

std::basic_filebuf b1;

int main()
{
  b1.open("foo");
  cout.rdbuf( b1 );
  std::cout << "hello" << std::endl;
  return 0;
}
// at program termination, b1 is deleted by 
// ios_base::Init::_S_ios_destroy,
// and the streambuf created to handle output
// to stdout is leaked.
>Fix:
create three global filebuf's in globals.cc.
add constructors in ios.cc to in-place construct and destroy these filebufs.
modify the constructors for cout/cin/cerr/clog in ios.cc to use these filebufs.
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-06-04  1:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-04  1:26 theonetruekenny [this message]
2001-06-08 13:08 bkoz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010604082334.25473.qmail@sourceware.cygnus.com \
    --to=theonetruekenny@yahoo.com \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=kenny.simpson@gs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).