Hi, the following testcase: #include <string> static int main_worker(int argc) { std::string s[32]; // [31] => no segfault if (argc < 2) throw 42; return argc; } int main(int argc, char **argv) { try { return main_worker(argc); } catch (int i) { return i; } } produces with optimization -O2 on execution the message: "terminate called after throwing an instance of 'int'" and abort gets called. If compiled with optimization level -O1, execution works as expected.
*** Bug 56747 has been marked as a duplicate of this bug. ***
Hmm, yes indeed it is the -freorder-blocks option. One solution is to disallow after reload for SEH-target to modify jumps. The following patch fixes the issue for me. Index: i386.c =================================================================== --- i386.c (Revision 197118) +++ i386.c (Arbeitskopie) @@ -3941,6 +3941,19 @@ register_pass (&insert_vzeroupper_info); } +/* Implement TARGET_CANNOT_MODIFY_JUMPS_P. */ +static bool +ix86_cannot_modify_jumps_p (void) +{ + if (TARGET_SEH && reload_completed + && cfun) + return true; + return false; +} + +#undef TARGET_CANNOT_MODIFY_JUMPS_P +#define TARGET_CANNOT_MODIFY_JUMPS_P ix86_cannot_modify_jumps_p + /* Update register usage after having seen the compiler flags. */ static void
(In reply to comment #2) > Hmm, yes indeed it is the -freorder-blocks option. One solution is to > disallow after reload for SEH-target to modify jumps. That's an awfully big hammer. Perhaps it's possible to first analyze what is actually happening in bbreorder that causes this bug?
(In reply to comment #3) > (In reply to comment #2) > > Hmm, yes indeed it is the -freorder-blocks option. One solution is to > > disallow after reload for SEH-target to modify jumps. > > That's an awfully big hammer. Perhaps it's possible to first analyze > what is actually happening in bbreorder that causes this bug? Well, the issue is analyzed. The issue is that SEH is table-based EH, and so after bb-reorder used labels for describing eh-regions are getting invalid. If you take a look to the produces assembly for the example, you will notice that easily. I admit that the first patch is a bit too invasive, as it disables bb-reorder in all cases. But in fact we need to disable it just if there is a catch-region. A more improved variant is: Index: i386.c =================================================================== --- i386.c (Revision 197118) +++ i386.c (Arbeitskopie) @@ -3941,6 +3941,20 @@ register_pass (&insert_vzeroupper_info); } +/* Implement TARGET_CANNOT_MODIFY_JUMPS_P. */ +static bool +ix86_cannot_modify_jumps_p (void) +{ + if (TARGET_SEH && reload_completed + && cfun && cfun->eh + && cfun->eh->region_tree) + return true; + return false; +} + +#undef TARGET_CANNOT_MODIFY_JUMPS_P +#define TARGET_CANNOT_MODIFY_JUMPS_P ix86_cannot_modify_jumps_p + /* Update register usage after having seen the compiler flags. */ static void
I can't reproduce this on x86_64-unknown-linux-gnu. Is it a regression? Changing component to rtl-optimization.
Well, this issue is related to SEH exceptions. So it is pretty clear, why you don't see it for linux. It is serious bug for 4.8 gcc. From user's perspective this is a regression. Technical it is a bug in bb-reorder for SEH. For 4.8 I think the above patch is the lowest invasive way to fix it. For trunk we might be able to use an approach as dw2 uses here. Not sure about later. I will discuss with Richard Henderson.
Does it work with 4.9? If not, it should be marked as 4.8/4.9 Regression.
Mine.
Created attachment 30168 [details] proposed patch Kudos to Kai for finally figuring out what was going wrong inside the system unwinder, and why. I believe this patch will fix the problem -- at least it does for this test case. A full test cycle is just commencing...
Created attachment 30169 [details] proposed patch 2 Fixes a dwarf2 ICE caused by the previous version. Full testing just restarting...
Fixed.
Created attachment 31834 [details] save output log and debug window log (at end)
Hello. I also observed the 64bit compile problem while muxing. And after using the new build the problem is indeed resolved. However I still see a remnant wxwiget error in the logs that you may wish to fix as well. Error is In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.). This is the pre-fix log. The post-fix log is below. mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan 8 2014 15:10:52 'notrealfilename.avi': Using the demultiplexer for the format 'AVI'. 'notrealfilename.avi' track 0: Using the output module for the format 'MPEG-4'. 'notrealfilename.avi' track 1: Using the output module for the format 'AC3'. The file 'notrealfilename (1).mkv' has been opened for writing. Progress: 0% [Fails with return code 3] Output of Debug window: 12:34:22: dpi is 96/96 12:34:22: Querying mkvmerge's capabilities 12:34:23: Capability: VERSION=mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan 8 2014 15:10:52 12:34:23: Capability: 12:34:23: Capability: FLAC 12:34:23: Capability: 12:34:23: about to check... btw int? 0 12:34:23: update state changed, now 1 12:34:26: update state changed, now 2 12:34:32: identify 1: command: ``"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" "@C:\Users\notme\AppData\Local\Temp\mmg-mkvmerge-options-3992-1389731672"'' 12:34:33: identify 1: result: 0 12:34:33: identify 1: output[0]: ``File 'notrealfilename.avi': container: AVI [is_providing_timecodes:1]'' 12:34:33: identify 1: output[1]: ``'' 12:34:33: identify 1: output[2]: ``Track ID 0: video (MPEG-4p2)'' 12:34:33: identify 1: output[3]: ``'' 12:34:33: identify 1: output[4]: ``Track ID 1: audio (AC3/EAC3)'' 12:34:33: identify 1: output[5]: ``'' 12:36:58: Locale selection logic: select_locale English (English) uu_locale_lower en translation_c::get_default_ui_locale() en app->m_ui_locale en 12:37:20: Querying mkvmerge's capabilities 12:37:20: Capability: VERSION=mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan 8 2014 15:10:52 12:37:20: Capability: 12:37:20: Capability: FLAC 12:37:20: Capability: In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.). In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.). In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.). In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.). 12:57:49: dpi is 96/96 12:57:49: Querying mkvmerge's capabilities 12:57:49: Capability: VERSION=mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan 8 2014 15:10:52 12:57:49: Capability: 12:57:49: Capability: FLAC 12:57:49: Capability: 12:58:00: identify 1: command: ``"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" "@C:\Users\Marty\AppData\Local\Temp\mmg-mkvmerge-options-4540-1389733080"'' 12:58:01: identify 1: result: 0 12:58:01: identify 1: output[0]: ``File 'notrealfilename.avi': container: AVI [is_providing_timecodes:1]'' 12:58:01: identify 1: output[1]: ``'' 12:58:01: identify 1: output[2]: ``Track ID 0: video (MPEG-4p2)'' 12:58:01: identify 1: output[3]: ``'' 12:58:01: identify 1: output[4]: ``Track ID 1: audio (AC3/EAC3)'' 12:58:01: identify 1: output[5]: ``'' In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.). mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan 11 2014 10:17:39 'notrealfilename.avi': Using the demultiplexer for the format 'AVI'. 'notrealfilename.avi' track 0: Using the output module for the format 'MPEG-4'. 'notrealfilename.avi' track 1: Using the output module for the format 'AC3'. The file 'notrealfilename (2).mkv' has been opened for writing. Progress: 0% [omitted lines] Progress: 100% The cue entries (the index) are being written... Muxing took 53 seconds. Output of Debug window: 13:01:17: dpi is 96/96 13:01:17: Querying mkvmerge's capabilities 13:01:17: Capability: VERSION=mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan 11 2014 10:17:39 13:01:17: Capability: 13:01:17: Capability: FLAC 13:01:17: Capability: 13:01:36: identify 1: command: ``"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" "@C:\Users\notme\AppData\Local\Temp\mmg-mkvmerge-options-4456-1389733296"'' 13:01:37: identify 1: result: 0 13:01:37: identify 1: output[0]: ``File 'notrealfilename.avi': container: AVI [is_providing_timecodes:1]'' 13:01:37: identify 1: output[1]: ``Track ID 0: video (MPEG-4p2)'' 13:01:37: identify 1: output[2]: ``Track ID 1: audio (AC3/EAC3)'' 13:01:37: identify 1: output[3]: ``'' In file /home/mosu/prog/video/mingw/cross-git-all/tmp-wxwidgets/wxWidgets-3.0.0/src/msw/window.cpp at line 576: 'SetFocus' failed with error 0x00000057 (the parameter is incorrect.).