Bug 38920 - dw2 exceptions don't work.
Summary: dw2 exceptions don't work.
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-20 02:50 UTC by Pawel Sikora
Modified: 2010-10-02 08:51 UTC (History)
4 users (show)

See Also:
Host: x86_64-gnu-linux
Target: x86_64-mingw32
Build: x86_64-gnu-linux
Known to work:
Known to fail:
Last reconfirmed: 2009-01-20 06:07:57


Attachments
testcase (130.12 KB, application/octet-stream)
2009-01-20 02:51 UTC, Pawel Sikora
Details
testcase (140.97 KB, application/octet-stream)
2009-01-25 09:57 UTC, Pawel Sikora
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2009-01-20 02:50:22 UTC
$ x86_64-mingw32-g++ -v
Reading specs from /usr/lib64/gcc/x86_64-mingw32/4.4.0/specs
Target: x86_64-mingw32
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--includedir=/usr/x86_64-mingw32/include --with-gnu-as --with-gnu-ld
--with-sysroot=/usr/x86_64-mingw32 --enable-shared --enable-threads=win32
--disable-sjlj-exceptions --enable-languages=c,c++ --enable-c99
--enable-long-long --enable-decimal-float=yes --enable-multilib
--enable-cmath --disable-nls --with-gnu-as --with-gnu-ld
--with-mangler-in-ld
--with-gxx-include-dir=/usr/x86_64-mingw32/include/c++/4.4.0
--disable-libstdcxx-pch --enable-__cxa_atexit --disable-libmudflap
--disable-libssp --with-pkgversion=PLD-Linux
--with-bugurl=http://bugs.pld-linux.org
--build=x86_64-pld-linux --host=x86_64-pld-linux --target=x86_64-mingw32
Thread model: win32
gcc version 4.4.0 20090116 (experimental) (PLD-Linux)



a simple testcase that throws an exception from test.dll
into main.exe causes an error:

d:\w64\main.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

afaics the test.dll exports all these typeinfos:

[Ordinal/Name Pointer] Table
        [   0] _Z9exceptionv
        [   1] _ZN2ExC1ERKSs
        [   2] _ZN2ExC2ERKSs
        [   3] _ZN2ExD0Ev
        [   4] _ZN2ExD1Ev
        [   5] _ZTI2Ex
        [   6] _ZTISt13runtime_error
        [   7] _ZTISt9exception
        [   8] _ZTS2Ex
        [   9] _ZTSSt13runtime_error
        [  10] _ZTSSt9exception
        [  11] _ZTV2Ex

but the main.exe import only one symbol from test.dll:

DLL Name: test.dll
        vma:  Hint/Ord Member-Name Bound-To
        13a70       0  _Z9exceptionv

DLL Name: libgcc_s_1.dll
        vma:  Hint/Ord Member-Name Bound-To
        135ac       1  _Unwind_DeleteException
        135c8       6  _Unwind_GetDataRelBase
        135e4       9  _Unwind_GetIPInfo
        135f8      10  _Unwind_GetLanguageSpecificData
        1361c      11  _Unwind_GetRegionStart
        13638      12  _Unwind_GetTextRelBase
        13654      13  _Unwind_RaiseException
        13670      14  _Unwind_Resume
        13684      15  _Unwind_Resume_or_Rethrow
        136a0      16  _Unwind_SetGR
        136b0      17  _Unwind_SetIP
        136c0      35  __deregister_frame_info
        136dc      83  __register_frame_info

full example attached.
Comment 1 Pawel Sikora 2009-01-20 02:51:25 UTC
Created attachment 17149 [details]
testcase
Comment 2 Danny Smith 2009-01-20 06:07:57 UTC
libstdc++ also needs to be built and linked in as dll.

Search mingw archive lists for other examples and approaches.

Danny
Comment 3 Pawel Sikora 2009-01-20 08:41:47 UTC
(In reply to comment #2)
> libstdc++ also needs to be built and linked in as dll.

i'm passing --enable-shared to gcc's configure but it only
creates shared libgcc_s_1.dll. libstdc++ is still static.
should i applay some magic patch on the top of 4.4 to get more dlls?

> Search mingw archive lists for other examples and approaches.

i've found two interest examples:

[Mingw-users] DW2 EH works "sometimes"
http://marc.info/?l=mingw-users&m=114984388106110&w=4

[Mingw-w64-public] SEH doesn't work on mingw-w64
http://www.mail-archive.com/mingw-w64-public@lists.sourceforge.net/msg00150.html

the rest of googled threads are about patches already committed for 4.4.
Comment 4 Pawel Sikora 2009-01-25 09:57:01 UTC
adding try{throw 0;}catch(...){} to main() shows that dw2-exceptions
don't work at all, so it's not related to dll crossing.
new testcase attached.
Comment 5 Pawel Sikora 2009-01-25 09:57:37 UTC
Created attachment 17180 [details]
testcase
Comment 6 Pawel Sikora 2009-01-25 10:02:30 UTC
maybe this bug is related to PR38952.
Comment 7 Danny Smith 2009-01-26 03:30:36 UTC
AFAICT DW2 unwind has never worked on x86_64-mingw32, which is why Kai made sjlj the default EH model for that target.
http://gcc.gnu.org/ml/gcc-patches/2007-12/msg00273.html
Comment 8 Pawel Sikora 2009-01-26 19:31:32 UTC
(In reply to comment #7)
> AFAICT DW2 unwind has never worked on x86_64-mingw32, which is why Kai made
> sjlj the default EH model for that target.
> http://gcc.gnu.org/ml/gcc-patches/2007-12/msg00273.html

ok, with sjlj and shared libgcc exceptions seem to work across dlls.
Comment 9 janus 2009-04-07 07:25:02 UTC
Subject: Bug 38920

Author: janus
Date: Tue Apr  7 07:24:37 2009
New Revision: 145651

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145651
Log:
2009-04-07  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/38920
	* expr.c (gfc_check_pointer_assign): Enable interface check for
	procedure pointers.
	* gfortran.h: Add copy_formal_args_intr.
	* interface.c (gfc_compare_interfaces): Call gfc_compare_intr_interfaces
	if second argument is an intrinsic.
	(compare_intr_interfaces): Correctly set attr.function, attr.subroutine
	and ts.
	(compare_parameter): Call gfc_compare_interfaces also for intrinsics.
	* resolve.c (resolve_specific_f0,resolve_specific_s0): Don't resolve
	intrinsic interfaces here. Must happen earlier.
	(resolve_symbol): Resolution of intrinsic interfaces moved here from
	resolve_specific_..., and formal args are now copied from intrinsic
	interfaces.
	* symbol.c (copy_formal_args_intr): New function to copy the formal
	arguments from an intinsic procedure.


2009-04-07  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/38920
	* gfortran.dg/proc_decl_1.f90: Modified.
	* gfortran.dg/proc_ptr_11.f90: Extended.
	* gfortran.dg/proc_ptr_13.f90: Modified.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/proc_decl_1.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_11.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_13.f90

Comment 10 janus 2009-04-07 07:34:58 UTC
Oops. The commit in comment #9 was actually for PR38290, but I accidentally messed up the PR number in the ChangeLog. Sorry for the noise.
Comment 11 Kai Tietz 2009-08-30 08:33:36 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > AFAICT DW2 unwind has never worked on x86_64-mingw32, which is why Kai made
> > sjlj the default EH model for that target.
> > http://gcc.gnu.org/ml/gcc-patches/2007-12/msg00273.html
> 
> ok, with sjlj and shared libgcc exceptions seem to work across dlls.
> 

This is right, that dw2 exception handling doesn't work for x64. As the x86 is absolutely incompatible to the x64 exception handling, there is the support of SEH2 unwind-data to be added. I begun already with support on gas to generate the pdata/xdata data by pseudo-opcodes. I plan to support this feature for 4.6.x (and maybe a 4.5.x). So for now, just sjlj exception handling is possible for x64 windows.
Comment 12 Kai Tietz 2010-10-02 08:51:15 UTC
It isn't planned to support dw2 exception mechanism for x64 windows. So I close this bug as won't be fixed