🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.lib.bug
Article #97

core dump if writing more than 8192 bytes to cerr

#97
From: Frank Breure .
Date: Thu, 16 Apr 1992 15:03
58 lines
2499 bytes
Hello,

I noticed the following bug:

If writing more than 8192 characters to cerr, doesn't matter in how
many different small chunks, you get a segmentation violation.
Gdb says it's in filebuf:overflow() or streambuf::pptr() this depends
whether it is compiled with -g.

I saw this problem on both installations I have:
using:

libg++ version 2.0
gcc 2.0

on:
Sun Sparc station with SunOs 4.1.1
DECstation 5000 with Ultrix 4.2

I made the following patch which works for me, but I don't think
I really fixed the bug. 
It is probably only a workaround.


------ begin of patch -----
*** libg++/iostream/stdstreams.C	Thu Apr 16 12:04:32 1992
--- libg++/iostream/stdstreams.C~	Thu Apr  2 16:02:12 1992
***************
*** 62,72 ****
   (streambuf*)&SBUF, TIE, 0, ios::dont_close|ios::skipws|EXTRA_FLAGS, ' ', 0, 6
  
  STR_NAME(_fake_ostream, cout)  = { STD_STR(_cout_sbuf, NULL, 0) };
- // changed by Frank Breure because of an annoying bug in writing to
- // cerr which made it impossible to write more than 8192 (== ios::unitbuf)
- // to cerr !!
  STR_NAME(_fake_ostream, cerr) =
!   { STD_STR(_cerr_sbuf, (ostream*)&cout, 0) };
  STR_NAME(_fake_istream, cin)  = { STD_STR(_cin_sbuf,  (ostream*)&cout, 0) };
  
  /* Only for (partial) compatibility with AT&T's library. */
--- 62,69 ----
   (streambuf*)&SBUF, TIE, 0, ios::dont_close|ios::skipws|EXTRA_FLAGS, ' ', 0, 6
  
  STR_NAME(_fake_ostream, cout)  = { STD_STR(_cout_sbuf, NULL, 0) };
  STR_NAME(_fake_ostream, cerr) =
!   { STD_STR(_cerr_sbuf, (ostream*)&cout, ios::unitbuf) };
  STR_NAME(_fake_istream, cin)  = { STD_STR(_cin_sbuf,  (ostream*)&cout, 0) };
  
  /* Only for (partial) compatibility with AT&T's library. */
---- end of patch ----

I hope this is of some help for you,

--
Frank Breure                                       (breure@iti.tno.nl)
TNO Institute of Applied Computer Science       Delft, The Netherlands
----------------------------------------------------------------------
My opinions may be subject to change without notice.
Technical Details
Message-ID: <9204161303.AA00621@iti.tno.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!iti.tno.NL!breure

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!iti.tno.NL!breure
From: breure@iti.tno.NL (Frank Breure .)
Subject: core dump if writing more than 8192 bytes to cerr
Message-ID: <9204161303.AA00621@iti.tno.nl>
Sender: gnulists@ai.mit.edu
Reply-To: breure@iti.tno.nl
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 16 Apr 1992 15:03:33 GMT
Approved: bug-lib-g++@prep.ai.mit.edu
Lines: 59