Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT cygwin DOT com Delivered-To: mailing list cygwin-developers AT cygwin DOT com X-Authentication-Warning: atacama.four-d.de: mail set sender to using -f Date: Fri, 8 Nov 2002 11:28:26 +0100 (=?ISO-8859-1?Q?Westeurop=E4ische_Normalzeit?=) From: Thomas Pfaff To: Danny Smith cc: mingw-dvlpr AT lists DOT sourceforge DOT net, Subject: Exception handling in gcc-3 Message-ID: X-X-Sender: pfaff AT antarctica DOT intern DOT net MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="1332970-2562-1036750926=:308" Content-ID: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime AT docserver DOT cac DOT washington DOT edu for more info. --1332970-2562-1036750926=:308 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: Hi Danny, i just had the time to look at the eh changes in gcc-3 for throwing exceptions across DLL/EXE boundaries. While the code works in 99% for cygwin and mingw it has one disadvantage for cygwin: The atom name is lost after a fork. See following example: #include #include #include #include #include using namespace std; #define WIN32_LEAN_AND_MEAN #include #define SHAREDPTR_LETTER0 'a' #define SHAREDPTR_LETTER1 'A' int main (void) { char s[sizeof(void*) * 8 + 1]; ATOM atom; try { memset (s, SHAREDPTR_LETTER0, sizeof(void*) * 8); s[sizeof(void*) * 8] = '\0'; switch (fork ()) { case -1: return 0; case 0: atom = FindAtomA (s); throw "child"; default: atom = FindAtomA (s); throw "parent"; } } catch (const char *str) { char szAtom[16]; sprintf( szAtom, "0x%08x", (int) atom ); cout << "got " << str << "s exception, atom " << szAtom << endl; } catch (...) { cout << "got exception" << endl; } return 0; } If a dll is loaded dynamically after a fork the shared information is lost and throwing exceptions from a dll does not work anymore. For that reason i have created a different version that uses a shared pointer that is contained in the cygwin1.dll, now it works in all test cases. (And since i always link against libmingwthrd.a i added this function to mthr.c too, but this is not applicable for all mingw users). I have attached my code. You may notice that i have moved 2 additional static vars in the shared area (object_mutex and marker from unwind-dw2-fde.c) and that i have modified the shared pointer allocation a bit. Comments are welcome. Thomas --1332970-2562-1036750926=:308 Content-Type: TEXT/PLAIN; NAME="eh_shared.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: ATTACHMENT; FILENAME="eh_shared.c" LyogZWhfc2hhcmVkLmM6IGV4Y2VwdGlvbiBoYW5kbGluZyBzdXBwb3J0IGZv ciBnY2MtM3guCgogICBDb3B5cmlnaHQgMjAwMiBSZWQgSGF0LCBJbmMuCgpU aGlzIGZpbGUgaXMgcGFydCBvZiBDeWd3aW4uCgpUaGlzIHNvZnR3YXJlIGlz IGEgY29weXJpZ2h0ZWQgd29yayBsaWNlbnNlZCB1bmRlciB0aGUgdGVybXMg b2YgdGhlCkN5Z3dpbiBsaWNlbnNlLiAgUGxlYXNlIGNvbnN1bHQgdGhlIGZp bGUgIkNZR1dJTl9MSUNFTlNFIiBmb3IKZGV0YWlscy4gKi8KCnZvaWQgKiog X19nZXRfdzMyX2VoX3NoYXJlZHB0ciAodm9pZCkKewogICBzdGF0aWMgdm9p ZCAqdzMyX2VoX3NoYXJlZHB0cjsKCiAgIHJldHVybiAmdzMyX2VoX3NoYXJl ZHB0cjsKfQoK --1332970-2562-1036750926=:308 Content-Type: TEXT/PLAIN; NAME="w32-shared-ptr.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: ATTACHMENT; FILENAME="w32-shared-ptr.c" LyoKICogdzMyLXNoYXJlZC1wdHIuYwogKgogKiBTaGFyZSBpbmZvcm1hdGlv bnMgYmV0d2VlbiBFWEUvRExMcy4KICoKICogQ29udHJpYnV0b3JzOgogKiAg Q3JlYXRlZCBieSBUaG9tYXMgUGZhZmYgPHRwZmFmZkBnbXgubmV0PgogKgog KiAgVEhJUyBTT0ZUV0FSRSBJUyBOT1QgQ09QWVJJR0hURUQKICoKICogIFRo aXMgc291cmNlIGNvZGUg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ZWN0X211dGV4X29uY2UgPSAmdzMyX2VoX3NoYXJlZHB0ci0+ aW5pdF9vYmplY3RfbXV0ZXhfb25jZTsKI2VuZGlmCiAgX193MzJfc2hhcmVk cHRyX21hcmtlciA9ICZ3MzJfZWhfc2hhcmVkcHRyLT5tYXJrZXI7Cn0K --1332970-2562-1036750926=:308 Content-Type: TEXT/PLAIN; NAME="unwind.patch" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: ATTACHMENT; FILENAME="unwind.patch" LS0tIHVud2luZC1kdzItZmRlLmMub3JnCTIwMDItMDgtMTYgMTY6NTU6MTcu MDAwMDAwMDAwICswMjAwCisrKyB1bndpbmQtZHcyLWZkZS5jCTIwMDItMTAt MTYgMDk6MzA6NDcuMDAwMDAwMDAwICswMjAwCkBAIC01MywxMSArNTMsMTcg QEAgZXh0ZXJuIHZvaWQqKiBfX3czMl9zaGFyZWRwdHJfc2Vlbl9vYmplYwog I2RlZmluZSBzZWVuX29iamVjdHMgICAgKCooc3RydWN0IG9iamVjdCoqKSgg X193MzJfc2hhcmVkcHRyX3NlZW5fb2JqZWN0cykpCiAjZW5kaWYKIAorI2lm ICEoZGVmaW5lZCAoX19NSU5HVzMyX18gKSB8fCBkZWZpbmVkIChfX0NZR1dJ Tl9fKSkKICNpZmRlZiBfX0dUSFJFQURfTVVURVhfSU5JVAogc3RhdGljIF9f Z3RocmVhZF9tdXRleF90IG9iamVjdF9tdXRleCA9IF9fR1RIUkVBRF9NVVRF WF9JTklUOwogI2Vsc2UKIHN0YXRpYyBfX2d0aHJlYWRfbXV0ZXhfdCBvYmpl Y3RfbXV0ZXg7CiAjZW5kaWYKKyNlbHNlCitleHRlcm4gdm9pZCAqIF9fdzMy X3NoYXJlZHB0cl9vYmplY3RfbXV0ZXg7CisjZGVmaW5lIG9iamVjdF9tdXRl eCAgKCooX19ndGhyZWFkX211dGV4X3QqKSggX193MzJfc2hhcmVkcHRyX29i amVjdF9tdXRleCkpCisjZW5kaWYKKwog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