]> sourceware.org Git - newlib-cygwin.git/commitdiff
* exceptions.cc (_cygtls::handle_exceptions): Only call rtl_unwind when
authorChristopher Faylor <me@cgf.cx>
Sat, 1 Mar 2008 13:18:22 +0000 (13:18 +0000)
committerChristopher Faylor <me@cgf.cx>
Sat, 1 Mar 2008 13:18:22 +0000 (13:18 +0000)
exiting.  Just return, don't set thread context.
* gendef (_setjmp): Store %fs:0 in jmp_buf.
(_sjfault): Ditto.
(_ljfault): Restore %fs:0 from jmp_buf.
(_longjmp): Ditto.

winsup/cygwin/ChangeLog
winsup/cygwin/cygtls.cc
winsup/cygwin/exceptions.cc
winsup/cygwin/gendef

index 1e5896fb50db68e0c2ecc79fad4a0fad75c56387..94a578851695a0f0f2c1924679cfa2e941702605 100644 (file)
@@ -1,3 +1,12 @@
+2008-03-01  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exceptions.cc (_cygtls::handle_exceptions): Only call rtl_unwind when
+       exiting.  Just return, don't set thread context.
+       * gendef (_setjmp): Store %fs:0 in jmp_buf.
+       (_sjfault): Ditto.
+       (_ljfault): Restore %fs:0 from jmp_buf.
+       (_longjmp): Ditto.
+
 2008-02-29  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Call close_fs
index 6b7e0cd5127dd1a298bea4aca1f885e170388419..34ba149345586696042f5206413464c801121ed5 100644 (file)
@@ -247,8 +247,7 @@ _cygtls::handle_threadlist_exception (EXCEPTION_RECORD *e, exception_list *frame
   extern void *threadlist_exception_return;
   cygheap->threadlist[threadlist_ix]->remove (INFINITE);
   threadlist_ix = 0;
-  RtlUnwind (frame, threadlist_exception_return, e, 0);
-  /* Never returns */
+  return 0;
 }
 
 /* Set up the exception handler for the current thread.  The x86 uses segment
index 3b4184db03beeea795484c1de925702c646c4034..56f19185110bd51ca01d7637f1ae6ce6668c90c9 100644 (file)
@@ -599,8 +599,6 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
       return 1;
     }
 
-  rtl_unwind (frame, e);
-
   debug_printf ("In cygwin_except_handler exc %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp);
   debug_printf ("In cygwin_except_handler sig %d at %p", si.si_signo, in->Eip);
 
@@ -650,6 +648,7 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
              goto out;
            }
 
+         rtl_unwind (frame, e);
          open_stackdumpfile ();
          exception (e, in);
          stackdump ((DWORD) ebp, 0, 1);
@@ -680,21 +679,8 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
   sig_send (NULL, si, &me);    // Signal myself
   me.incyg--;
   e->ExceptionFlags = 0;
-  /* The OS adds an exception list frame to the stack.  It expects to be
-     able to remove this entry after the exception handler returned.
-     However, when unwinding to our frame, our frame becomes the uppermost
-     frame on the stack (%fs:0 points to frame).  This way, our frame
-     is removed from the exception stack and just disappears.  So, we can't
-     just return here or things will be screwed up by the helpful function
-     in (presumably) ntdll.dll.
-
-     So, instead, we will do the equivalent of a longjmp here and return
-     to the caller without visiting any of the helpful code installed prior
-     to this function.  This should work ok, since a longjmp() out of here has
-     to work if linux signal semantics are to be maintained. */
 out:
-  SetThreadContext (GetCurrentThread (), in);
-  return 0; /* Never actually returns.  This is just to keep gcc happy. */
+  return 0;
 }
 
 /* Utilities to call a user supplied exception handler.  */
index 0d7df4b090c2213eb98be9dec4c818e9d21760bb..28d4b3125fd0fe05d8ed5cd3a42d9df4aec4db73 100755 (executable)
@@ -332,12 +332,14 @@ _setjmp:
        movw    %ax,40(%edi)
        movw    %ss,%ax
        movw    %ax,42(%edi)
+       movl    %fs:0,%eax
+       movl    %eax,44(%edi)
        pushl   %ebx
        call    stabilize_sig_stack
        movl    $tls::stackptr(%ebx),%eax               # save stack pointer contents
        decl    $tls::stacklock(%ebx)
        popl    %ebx
-       movl    %eax,44(%edi)
+       movl    %eax,48(%edi)
        popl    %edi
        movl    \$0,%eax
        leave
@@ -371,6 +373,8 @@ ___sjfault:
        movw    %ax,40(%edi)
        movw    %ss,%ax
        movw    %ax,42(%edi)
+       movl    %fs:0,%eax
+       movl    %eax,44(%edi)
        popl    %edi
        movl    \$0,%eax
        leave
@@ -391,6 +395,8 @@ ___ljfault:
        movl    24(%edi),%ebp
        pushfl
        popl    %ebx
+       movl    44(%edi),%eax
+       movl    %eax,%fs:0
        movw    42(%edi),%ax
        movw    %ax,%ss
        movl    28(%edi),%esp
@@ -415,7 +421,7 @@ _longjmp:
        movl    %esp,%ebp
        movl    8(%ebp),%edi                            # address of buffer
        call    stabilize_sig_stack
-       movl    44(%edi),%eax                           # get old signal stack
+       movl    48(%edi),%eax                           # get old signal stack
        movl    %eax,$tls::stackptr(%ebx)               # restore
        decl    $tls::stacklock(%ebx)                   # relinquish lock
        xorl    %eax,%eax
@@ -430,6 +436,8 @@ _longjmp:
        movl    24(%edi),%ebp
        pushfl
        popl    %ebx
+       movl    44(%edi),%eax
+       movl    %eax,%fs:0
        movw    42(%edi),%ax
        movw    %ax,%ss
        movl    28(%edi),%esp
This page took 0.040807 seconds and 5 git commands to generate.