Re: [PATCH 00/11] C++/MinGW patches

Pedro Alves
2015-11-17T14:50:13Z

On 11/09/2015 09:52 AM, Qian Hong wrote:
> Hi Pedro,
>

Hi Qian,

> Thanks for the info, I did some tests with your code.
>
> On Wed, Nov 4, 2015 at 6:39 AM, Pedro Alves <palves@redhat.com> wrote:
>> So it seems to me that something is wrong with C++ exceptions
>> support in the mingw toolchain you used. I suggest trying a simple
>> test like:
>>

>>
>> ... to check whether C++ exceptions work at all.
>
> The above test case works for me.
> I tried several thing:
> 1. build the above code with MINGW-w64 g++ from MSYS2, run on MSYS2.
> It works on both Windows and Wine.
> 2. build the above code with MinGW-w64 cross compiler from my Ubuntu,
> runs on Wine, works as expected.
> 3. build the above code with Linux native g++ (i386), runs on Linux,
> works as expected.
> 4. Added customer printf statement to the source code, retest on all
> configuration above, and I can confirm all executed code path are the
> same.
>
>
>> One issue to look out for is what flavor of C++ exceptions your mingw
>> toolchain uses. There are flavors using dwarf2, others using sjlj. Also, we
>> link gdb with -static-libstdc++ -static-libgcc, which may make a difference.
>
> I tried all 4 combination of with/without
> -static-libstdc++/-static-libgcc, the test case works for me on
> Windows with MinGW-w64 g++ from MSYS2.
>
> MSYS2 g++ has --disable-sjlj-exceptions --with-dwarf2, not sure if it
> does matter.

Could well be. The problem may be that a dwarf or seh exception
(not sure which is used nowadays, if sjlj exceptions are disabled)
is failing to cross some foreign frame (e.g., a system DLL).
A C++ gdb cross built with Fedora 20's mingw-w64 g++ (4.8.4) runs fine
on a Windows 7 machine I had handy here, and that doesn't seem to
have been built with --disable-sjlj-exceptions.

Since C mode still works fine after my patches, and I can't imagine that it's
this series that's creating the exceptions/C++ issue you're running into, I'm
going ahead with pushing the series in. We'll revisit later when we re-wire
THROW/CATCH to real C++ exceptions later on, if necessary.

Thanks,
Pedro Alves