public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Adam Fanello <afanello@Centor.com>
To: "'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>
Cc: Glen Knowles <gknowles@Centor.com>
Subject: c++/8026: -fstack-check dumps when throw out of scope with ostringstream
Date: Tue, 24 Sep 2002 17:16:00 -0000	[thread overview]
Message-ID: <012D0E417390D411ABD400A0C9175D8050D0E2@MAIL> (raw)


>Number:         8026
>Category:       c++
>Synopsis:       -fstack-check dumps when throw out of scope with
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 24 17:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     afanello@centor.com
>Release:        3.2
>Organization:
>Environment:
System: HP-UX hp11 B.11.00 U 9000/800 813839606 unlimited-user license


	
host: hppa2.0n-hp-hpux11.00
build: hppa2.0n-hp-hpux11.00
target: hppa2.0n-hp-hpux11.00
configured with: ./configure  : (reconfigured) ./configure  : (reconfigured)
./configure  : (reconfigured) ./configure  : (reconfigured) ./configure  :
(reconfigured) ./configure  : (reconfigured) ./configure  : (reconfigured)
./configure  : (reconfigured) ./configure  : (reconfigured) ./configure  :
(reconfigured) ./configure 
>Description:
Throwing out of a scope which contains a std::ostringstream when the program
was compiled with the -fstack-check option causes a SIGSEGV while unwinding
the stack.

>How-To-Repeat:

Source program: ctcore.cpp
---------------------------------------------------------------------------
#include <iostream>
#include <sstream>

using namespace std;
 

int main(int argc, const char** argv, const char** envp)
{
    try
    {
	 ostringstream msg;
	 throw 0;
    }
    catch (int ex)
    {
       cout << "Caught exception" << endl;
    }

    cout << "End program." << endl;
    return 0;
}
--------------------------------------------------------------------------

$ g++ -fstack-check ctcore.cpp
$ ./a.out
Segmentation fault (core dumped)
$

>Fix:
	Workaround: Don't use -fstack-check

------_=_NextPart_001_01C26428.3261B9D0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>-fstack-check dumps when throw out of scope with =
ostringstream</TITLE>
</HEAD>
<BODY>
<BR>

<P><FONT SIZE=3D2>&gt;Submitter-Id:&nbsp; net</FONT>
<BR><FONT SIZE=3D2>&gt;Originator:&nbsp;&nbsp;&nbsp; =
afanello@centor.com</FONT>
<BR><FONT SIZE=3D2>&gt;Organization:&nbsp; </FONT>
<BR><FONT SIZE=3D2>&gt;Confidential:&nbsp; no</FONT>
<BR><FONT SIZE=3D2>&gt;Synopsis:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
-fstack-check dumps when throw out of scope with ostringstream</FONT>
<BR><FONT SIZE=3D2>&gt;Severity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
serious</FONT>
<BR><FONT SIZE=3D2>&gt;Priority:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
medium</FONT>
<BR><FONT SIZE=3D2>&gt;Category:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
c++</FONT>
<BR><FONT SIZE=3D2>&gt;Class: =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wrong-code</FONT>
<BR><FONT SIZE=3D2>&gt;Release:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
3.2</FONT>
<BR><FONT SIZE=3D2>&gt;Environment:</FONT>
<BR><FONT SIZE=3D2>System: HP-UX hp11 B.11.00 U 9000/800 813839606 =
unlimited-user license</FONT>
</P>
<BR>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR><FONT SIZE=3D2>host: hppa2.0n-hp-hpux11.00</FONT>
<BR><FONT SIZE=3D2>build: hppa2.0n-hp-hpux11.00</FONT>
<BR><FONT SIZE=3D2>target: hppa2.0n-hp-hpux11.00</FONT>
<BR><FONT SIZE=3D2>configured with: ./configure&nbsp; : (reconfigured) =
./configure&nbsp; : (reconfigured) ./configure&nbsp; : (reconfigured) =
./configure&nbsp; : (reconfigured) ./configure&nbsp; : (reconfigured) =
./configure&nbsp; : (reconfigured) ./configure&nbsp; : (reconfigured) =
./configure&nbsp; : (reconfigured) ./configure&nbsp; : (reconfigured) =
./configure&nbsp; : (reconfigured) ./configure </FONT></P>

<P><FONT SIZE=3D2>&gt;Description:</FONT>
<BR><FONT SIZE=3D2>Throwing out of a scope which contains a =
std::ostringstream when the program</FONT>
<BR><FONT SIZE=3D2>was compiled with the -fstack-check option causes a =
SIGSEGV while unwinding</FONT>
<BR><FONT SIZE=3D2>the stack.</FONT>
</P>

<P><FONT SIZE=3D2>&gt;How-To-Repeat:</FONT>
</P>

<P><FONT SIZE=3D2>Source program: ctcore.cpp</FONT>
<BR><FONT =
SIZE=3D2>---------------------------------------------------------------=
------------</FONT>
<BR><FONT SIZE=3D2>#include &lt;iostream&gt;</FONT>
<BR><FONT SIZE=3D2>#include &lt;sstream&gt;</FONT>
</P>

<P><FONT SIZE=3D2>using namespace std;</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
</P>

<P><FONT SIZE=3D2>int main(int argc, const char** argv, const char** =
envp)</FONT>
<BR><FONT SIZE=3D2>{</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; try</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; {</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2> =
ostringstream msg;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2> =
throw 0;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; catch (int ex)</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; =
&quot;Caught exception&quot; &lt;&lt; endl;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; }</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; cout &lt;&lt; &quot;End =
program.&quot; &lt;&lt; endl;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; return 0;</FONT>
<BR><FONT SIZE=3D2>}</FONT>
<BR><FONT =
SIZE=3D2>---------------------------------------------------------------=
-----------</FONT>
</P>

<P><FONT SIZE=3D2>$ g++ -fstack-check ctcore.cpp</FONT>
<BR><FONT SIZE=3D2>$ ./a.out</FONT>
<BR><FONT SIZE=3D2>Segmentation fault (core dumped)</FONT>
<BR><FONT SIZE=3D2>$</FONT>
</P>

<P><FONT SIZE=3D2>&gt;Fix:</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>Workaround: Don't use -fstack-check</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C26428.3261B9D0--
>Release-Note:
>Audit-Trail:
>Unformatted:
 This message is in MIME format. Since your mail reader does not understand
 this format, some or all of this message may not be legible.
 
 ------_=_NextPart_001_01C26428.3261B9D0
 Content-Type: text/plain;
 	charset="iso-8859-1"
 
 
 ostringstream


                 reply	other threads:[~2002-09-25  0:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=012D0E417390D411ABD400A0C9175D8050D0E2@MAIL \
    --to=afanello@centor.com \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gknowles@Centor.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).