public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8026: -fstack-check dumps when throw out of scope with ostringstream
@ 2002-09-24 17:16 Adam Fanello
  0 siblings, 0 replies; only message in thread
From: Adam Fanello @ 2002-09-24 17:16 UTC (permalink / raw)
  To: 'gcc-gnats@gcc.gnu.org'; +Cc: Glen Knowles


>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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-25  0:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-24 17:16 c++/8026: -fstack-check dumps when throw out of scope with ostringstream Adam Fanello

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).