[Bug 1212162] New: Exception handling corrupts a VLA

bugzilla at redhat.com bugzilla at redhat.com
Wed Apr 15 17:07:36 UTC 2015


https://bugzilla.redhat.com/show_bug.cgi?id=1212162

            Bug ID: 1212162
           Summary: Exception handling corrupts a VLA
           Product: Fedora
           Version: 21
         Component: mingw32-gcc
          Assignee: rjones at redhat.com
          Reporter: hedayatv at gmail.com
        QA Contact: extras-qa at fedoraproject.org
                CC: erik-fedora at vanpienbroek.nl,
                    fedora-mingw at lists.fedoraproject.org,
                    kalevlember at gmail.com, rjones at redhat.com



Description of problem:
Code:
-----------------------------------------------------------------
#include <iostream>
#include <cstring>
#include <sstream>
#include <stdexcept>

using namespace std;

int main(int argc, char **argv)
{
        int n;
        stringstream ss(argv[1]);
        ss >> n;
        cout << "N: " << n << endl;
        char tbuff[n];
        try
        {
                memset(tbuff, 0, n);
                throw runtime_error("ERR");
        }
        catch (exception &e)
        {
                cout << "Writing to VLA" << endl;
                memset(tbuff, 0, n);
                cout << "Wrote" << endl;
        }
}
-----------------------------------------------------------------

Compiled with: 
/usr/bin/i686-w64-mingw32-g++ -O2  test.cpp -o t

Run with wine (similar results under Windows) results in crash:
[]% ./t 100                                         
fixme:winediag:start_process Wine Staging is a testing version containing
experimental patches.
fixme:winediag:start_process Please report bugs at http://bugs.wine-staging.com
(instead of winehq.org).
N: 100
Writing to VLA
wine: Unhandled page fault on read access to 0x00000000 at address (nil)
(thread 0009), starting debugger...
Unhandled exception: page fault on read access to 0x00000000 in 32-bit code
(0x00000000).
....

Version-Release number of selected component (if applicable):
mingw32-gcc-c++-4.9.2-1.fc21.x86_64

How reproducible:
100%

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Unsubscribe from this bug https://bugzilla.redhat.com/token.cgi?t=fSJiOBofWA&a=cc_unsubscribe


More information about the mingw mailing list