This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
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 <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <pthread.h>
#include <iostream>
using namespace std;
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#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
Attachment:
eh_shared.c
Description: Text document
Attachment:
w32-shared-ptr.c
Description: Text document
Attachment:
unwind.patch
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |