public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5757: segmentation fault in free during stack unwinding.
@ 2002-02-23  6:06 j.kuipers
  0 siblings, 0 replies; only message in thread
From: j.kuipers @ 2002-02-23  6:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5757
>Category:       c++
>Synopsis:       segmentation fault in free during stack unwinding.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 23 06:06:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Johan Kuipers
>Release:        3.0.3
>Organization:
>Environment:
System: Linux barrel 2.4.4-4GB #4 Sat Dec 1 23:57:55 CET 2001 i686 unknown
Architecture: i686
 
    Pentium II 450 Mhz, Linux/ELF
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0.3/configure --enable-threads --enable-shared --prefix=/usr/local/gcc-3.0.3
>Description:
If, during allocation of an array of T, one of the constructors throws an exception it causes a 'Segmentation fault' in function free(void*).
During stack unwinding operator delete[](void*) is called with an address different from the one returned by operator new[](unsigned).
In my example new returns 0x804aa80 while delete is passed 0x804aa84. I guess 4 is the array allocation overhead.
>How-To-Repeat:
Source file t.cpp with the following code:
 
class   X
{
public:
        X::X()
        {
            throw "";
        }
 
        X::~X()
        {
        }
};
 
int main()
{
    try
    {
        X* p = new X[4];
        delete [] p;
    }
    catch(...)
    {
    }
    return 0;
}
 
Compile with:
g++ -Wall -Werror t.cpp -o t
>Fix:
N/A
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="t.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="t.ii"

IyAxICJ0LmNwcCIKY2xhc3MgWAp7CnB1YmxpYzoKICAgICAgICAgICAgICAgIFg6OlgoKQogICAg
ICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAiIjsKICAgICAgICAg
ICAgICAgIH0KCiAgICAgICAgICAgICAgICBYOjp+WCgpCiAgICAgICAgICAgICAgICB7CiAgICAg
ICAgICAgICAgICB9Cn07CgppbnQgbWFpbigpCnsKICAgICAgICB0cnkKICAgICAgICB7CiAgICAg
ICAgICAgICAgICBYKiBwID0gbmV3IFhbNF07CiAgICAgICAgICAgICAgICBkZWxldGUgW10gcDsK
ICAgICAgICB9CiAgICAgICAgY2F0Y2goLi4uKQogICAgICAgIHsKICAgICAgICB9CiAgICAgICAg
cmV0dXJuIDA7Cn0K


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

only message in thread, other threads:[~2002-02-23 14:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-23  6:06 c++/5757: segmentation fault in free during stack unwinding j.kuipers

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