Bugs item #525603, was opened at 2002-03-04 11:56
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=102435&aid=525603&group_id=2435
Category: gcc
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Gravereaux (davygrvy)
Assigned to: Danny Smith (dannysmith)
Summary: Structured Exception Handling broken
Initial Comment:
Although the following compiles cleanly, it doesn't
work.
#include <windows.h>
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, int nCmdShow)
{
int a, b = 0;
__try {
a = 666 / b; /* divide by zero */
}
__except (EXCEPTION_EXECUTE_HANDLER) {
MessageBox(0, "went boom and caught", "",
MB_OK);
}
return 0;
}
----------------------------------------------------------------------
>Comment By: David Gravereaux (davygrvy)
Date: 2002-03-04 16:35
Message:
Logged In: YES
user_id=7549
That's good. I'll see what that does. Thanks!
----------------------------------------------------------------------
Comment By: Danny Smith (dannysmith)
Date: 2002-03-04 16:16
Message:
Logged In: YES
user_id=11494
I was thinking of using something like:
BOOL IsValid
UINT oldErrorMode = SetErrorMode
(SEM_FAILCRITICALERRORS); /* turn off SEM error handling) */
IsValid =CloseHandle(dupedHandle)) {
/* inspect the error value with GetLastError() if
necessary */
SetErrorMode(oldErrorMode); /* turn it back on */
if (!IsValid)
DoTheNotValidThing();
else
DoTheValidThing();
I do soemthing like that when testing if the user has a
disk in the A: drive.
----------------------------------------------------------------------
Comment By: David Gravereaux (davygrvy)
Date: 2002-03-04 15:51
Message:
Logged In: YES
user_id=7549
This is as close as I can get conceptualizing this. Do you
have any code samples? Thanks.
http://cvs.sourceforge.net/cgi-
bin/viewcvs.cgi/tcl/tcl/win/tclWinChan.c?rev=1.20&content-
type=text/vnd.viewcvs-markup
Index: tclWinChan.c
============================================================
=======
RCS file: /cvsroot/tcl/tcl/win/tclWinChan.c,v
retrieving revision 1.20
diff -c -r1.20 tclWinChan.c
*** tclWinChan.c 15 Feb 2002 14:28:51 -0000 1.20
--- tclWinChan.c 4 Mar 2002 23:27:45 -0000
***************
*** 983,989 ****
--- 983,1003 ----
* of this duped handle which might throw
EXCEPTION_INVALID_HANDLE.
*/
+ #ifdef __MINGW__
+ asm {
+ push ebp
+ mov ebp, esp
+ push -1
+ push <???safeSpot???>
+ push OFFSET FLAT:__except_handler3
+ mov eax, DWORD PTR fs:__except_list
+ push eax
+ mov DWORD PTR fs:__except_list, esp
+ }
+ {
+ #else
__try {
+ #endif
CloseHandle(dupedHandle);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
----------------------------------------------------------------------
Comment By: David Gravereaux (davygrvy)
Date: 2002-03-04 15:09
Message:
Logged In: YES
user_id=7549
Yes, exactly. I'd have to figure it out how to do it,
though. Not sure... I just looked at
http://www.jorgon.freeserve.co.uk/ExceptFrame.htm
#ifdef __MINGW__
asm {
push ebp
push <safeSpot>
push <exceptSpot>
push fs:[0]
mov fs:[0], esp
}
{
#else
__try {
#endif
??? I have no clue what I'm doing, nor do I know the AT&T
asm syntax :)
----------------------------------------------------------------------
Comment By: Danny Smith (dannysmith)
Date: 2002-03-04 14:54
Message:
Logged In: YES
user_id=11494
Would this work for your problem? Install a custom
exception handler that does the right thing for
STATUS_INVALID_HANDLE. Then revert back to the old handler.
Danny
----------------------------------------------------------------------
Comment By: David Gravereaux (davygrvy)
Date: 2002-03-04 14:13
Message:
Logged In: YES
user_id=7549
Sorry, I'd like to help, but I have too many hobbies
already ;)
Without a real implimentation of SEH, Tcl 8.4 crashes due
to a test that's run against a Win2K bug regarding garbage
in a GUI (WinMain) app's STARTUPINFO that's caused by the
default loader. Any call to GetStdHandle
(STD_OUTPUT_HANDLE) returns an invalid handle rather than
zero or INVALID_HANDLE_VALUE. Without an IsValidHandle()
function where Tcl uses SEH in the validity test, any
WinMain app that embedds Tcl, calls [puts] without a
redirection channel, and starts on Win2K, will crash when
MinGW compiled Tcl.
I'd change Tcl to not use SEH if there was any sort of
alternate approach that exists. But there doesn't seem to
be.
Ya know... I'll look into rewriting that part of Tcl in
inline assembly to see if I can get around the missing
intrinsic. Thanks.
----------------------------------------------------------------------
Comment By: Danny Smith (dannysmith)
Date: 2002-03-04 13:34
Message:
Logged In: YES
user_id=11494
This is not really a bug. It is a compiler feature that
has never been implemented in GCC. I believe that members
of the ReactOs team are working on patches to GCC to allow
SEH. Perhaps you could check on their progess and find out
what help they need.
Danny
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=102435&aid=525603&group_id=2435
|