diff options
author | mdejong <mdejong> | 2003-01-24 08:04:25 (GMT) |
---|---|---|
committer | mdejong <mdejong> | 2003-01-24 08:04:25 (GMT) |
commit | 709661acd4c4100385dc6779b3c10442599ae342 (patch) | |
tree | 2d9d1ae6937fa03c9a0e577aa1787aa117cfd304 /win/tclWin32Dll.c | |
parent | ffc4888f61c1b387a9b1263b73a538878e57a672 (diff) | |
download | tcl-709661acd4c4100385dc6779b3c10442599ae342.zip tcl-709661acd4c4100385dc6779b3c10442599ae342.tar.gz tcl-709661acd4c4100385dc6779b3c10442599ae342.tar.bz2 |
* win/configure: Regen.
* win/configure.in:
* win/tclWin32Dll.c (TclpCheckStackSpace): Rework
the SEH exception handler logic to avoid using
the stack since alloca will modify the stack.
This was causing a nasty bug that would set the
exception handler to 0 because it tried to pop
the previous exception handler off the top of
the stack.
Diffstat (limited to 'win/tclWin32Dll.c')
-rw-r--r-- | win/tclWin32Dll.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index ac9e8cd..1c029f8 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -9,11 +9,16 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWin32Dll.c,v 1.20 2003/01/16 19:01:59 mdejong Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.21 2003/01/24 08:04:29 mdejong Exp $ */ #include "tclWinInt.h" +#if defined(HAVE_NO_ALLOC_DECL) +void* __cdecl _alloca(size_t size); +#define alloca _alloca +#endif /* HAVE_NO_ALLOC_DECL */ + /* * The following data structures are used when loading the thunking * library for execing child processes under Win32s. @@ -40,6 +45,9 @@ static int platformId; /* Running under NT, or 95/98? */ #ifdef HAVE_NO_SEH static void *ESP; static void *EBP; +static void* HANDLER[2]; +static void* NEW_HANDLER = &(HANDLER[0]); +static void* OLD_HANDLER = &(HANDLER[1]); #endif /* HAVE_NO_SEH */ /* @@ -378,9 +386,12 @@ TclpCheckStackSpace() "movl %ebp, _EBP"); __asm__ __volatile__ ( - "pushl $__except_checkstackspace_handler" "\n\t" - "pushl %fs:0" "\n\t" - "mov %esp, %fs:0"); + "movl %fs:0, %eax" "\n\t" + "movl %eax, _OLD_HANDLER" "\n\t" + "movl __except_checkstackspace_handler, %eax" "\n\t" + "movl %eax, _NEW_HANDLER" "\n\t" + "movl _HANDLER, %eax" "\n\t" + "movl %eax, %fs:0"); #else __try { #endif /* HAVE_NO_SEH */ @@ -395,9 +406,8 @@ TclpCheckStackSpace() __asm__ __volatile__ ( "checkstackspace_pop:" "\n\t" - "mov (%esp), %eax" "\n\t" - "mov %eax, %fs:0" "\n\t" - "add $8, %esp"); + "mov _OLD_HANDLER, %eax" "\n\t" + "mov %eax, %fs:0"); #else } __except (EXCEPTION_EXECUTE_HANDLER) {} #endif /* HAVE_NO_SEH */ @@ -625,6 +635,9 @@ static void squelch_warnings() ptr = _except_checkstackspace_handler; ESP = 0; EBP = 0; + OLD_HANDLER = 0; + NEW_HANDLER = 0; + HANDLER[0] = 0; squelch_warnings(); } #endif /* HAVE_NO_SEH */ |