delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Date: | Wed, 24 Nov 2004 11:27:11 +1300 |
From: | Danny Smith <dannysmith AT clear DOT net DOT nz> |
Subject: | stdcall lib functions with exception throwing callbacks vs Dwarf2 EH |
To: | gcc AT gcc DOT gnu DOT org |
Cc: | Cygwin <cygwin AT cygwin DOT com>, |
mingw-dvlpr <mingw-dvlpr AT lists DOT sourceforge DOT net> | |
Reply-to: | Danny Smith <dannysmith AT users DOT sourceforge DOT net> |
Message-id: | <001701c4d1ab$949322e0$0a6d65da@DANNY> |
MIME-version: | 1.0 |
Hi, I've been trying to get DW2 EH exception handling working on windows targets with general success, but have hit a snag. If a C library function that takes a callback arg is compiled using stdcall convention, C++ exception thrown by the callback result in abort. If the C libarary function uses normal (cdelc) calling convention than exceptions thrown by callback are handled. Example: ============================================== /* callback.c library functions */ /* compile this with c */ void caller_c (void (*callback)(void)) { callback(); } void __attribute__((stdcall)) caller_s (void (*callback)(void)) { callback(); } ============================================== /* main.cc */ #include <stdio.h> extern "C" { typedef void (*foo)(void); extern void caller_c (foo); extern void __attribute__ ((__stdcall__)) caller_s (foo); } void callback (void) { printf ("Hello from callback\n"); fflush (stdout); throw 1; } int main () { try { printf ("Testing cdecl\n"); caller_c (callback); } catch (int) { printf ("Caught cdecl\n"); } try { printf ("\nTesting stdcall\n"); caller_s (callback); } catch (int) { printf ("Caught stdcall\n"); } return 0; } ================================================== Compiling with sjlj enabled compiler: gcc -c -o callback.o callback.c g++-sjlj -o main-sjlj.exe main.cc callback.o Both throws are caught. However, if using DW2 EH enabled compiler g++-dw2 -omain-dw2.exe main.cc callback.o I get this: > Testing cdecl > Hello from callback > Caught cdecl > Testing stdcall > Hello from callback > > abnormal program termination. This is significant for windows targets, since the OS win32 api uses stdcall almost exclusively. Before I pull any more hair out trying, does any one have any hints on how to use an MD_FALLBACK_FRAME_STATE_FOR to workaround, or is this a blocker for the use of DW2 EH on windows targets. Danny -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |