User account creation filtered due to spam.

Bug 56747 - throw segfaults on 64bit Cygwin if -O2 (-freorder-blocks) is used with g++ 4.8.0
Summary: throw segfaults on 64bit Cygwin if -O2 (-freorder-blocks) is used with g++ 4.8.0
Status: RESOLVED DUPLICATE of bug 56742
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-26 19:50 UTC by Christian Franke
Modified: 2013-03-27 01:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Franke 2013-03-26 19:50:47 UTC
The test program below segfaults during __cxa_throw if -O2 is used. The problem is possibly related to generation of unwinding-information in conjunction with -freorder-blocks optimization.

Testcase:

$ uname -srvmo
CYGWIN_NT-6.1 1.7.18(0.263/5/3) 2013-03-26 14:56 x86_64 Cygwin

$ g++ --version
g++ (GCC) 4.8.0

$ cat throw.cc
#include <string>

static int main_worker(int argc)
{
  std::string s[32];
  if (argc < 2)
    throw 42;
  return argc;
}

int main(int argc, char **argv)
{
  try {
    return main_worker(argc);
  }
  catch (int i) {
    return i;
  }
}

$ g++ -O1 -o throw throw.cc

$ ./throw; echo $?
42

$ g++ -O2 -o throw throw.cc

$ ./throw; echo $?
Segmentation fault
139

$ g++ -O2 -fno-reorder-blocks -o throw throw.cc

$ ./throw; echo $?
42

$ g++ -O1 -freorder-blocks -g -o throw throw.cc

$ ./throw; echo $?
Segmentation fault
139

$ gdb throw
...
(gdb) r
Starting program: /tmp/throw/throw
[New Thread 4164.0xe58]
[New Thread 4164.0x7e8]
gdb: unknown target exception 0x20474343 at 0x7fefd7c9e5d
Program received signal ?, Unknown signal.
0x000007fefd7c9e5d in RaiseException () from /cygdrive/c/Windows/system32/KERNELBASE.dll
Comment 1 Andrew Pinski 2013-03-26 20:11:28 UTC
Dup of bug 56742.

*** This bug has been marked as a duplicate of bug 56742 ***