* gendef (sigreturn): Call stabilize_sig_stack to ensure that there are no

pending signals.  Restore edx later.
(sigdelayed): Save edx earlier.
* malloc_wrapper.cc (malloc_init): Add some more debugging output.
This commit is contained in:
Christopher Faylor 2004-03-04 05:31:14 +00:00
parent 13a47bd66a
commit 08b0a057eb
5 changed files with 50 additions and 38 deletions

View File

@ -1,3 +1,11 @@
2004-03-03 Christopher Faylor <cgf@redhat.com>
* gendef (sigreturn): Call stabilize_sig_stack to ensure that there are
no pending signals. Restore edx later.
(sigdelayed): Save edx earlier.
* malloc_wrapper.cc (malloc_init): Add some more debugging output.
2004-03-02 Corinna Vinschen <corinna@vinschen.de> 2004-03-02 Corinna Vinschen <corinna@vinschen.de>
* fhandler_raw.cc (fhandler_dev_raw::raw_read): When reading with * fhandler_raw.cc (fhandler_dev_raw::raw_read): When reading with

View File

@ -1200,4 +1200,5 @@ reset_signal_arrived ()
{ {
(void) ResetEvent (signal_arrived); (void) ResetEvent (signal_arrived);
sigproc_printf ("reset signal_arrived"); sigproc_printf ("reset signal_arrived");
if (_my_tls.stackptr > _my_tls.stack) debug_printf ("stackptr[-1] %p", _my_tls.stackptr[-1]);
} }

View File

@ -128,8 +128,8 @@ __sigbe:
2: movl \$-4,%eax # now decrement aux stack 2: movl \$-4,%eax # now decrement aux stack
xadd %eax,$tls::stackptr(%edx) # and get pointer xadd %eax,$tls::stackptr(%edx) # and get pointer
xorl %ebx,%ebx xorl %ebx,%ebx
xchgl %ebx,-4(%eax) # xchgl %ebx,-4(%eax) # get return address from signal stack
xchgl %ebx,8(%esp) xchgl %ebx,8(%esp) # restore ebx/real return address
decl $tls::stacklock(%edx) # release lock decl $tls::stacklock(%edx) # release lock
popl %eax popl %eax
popl %edx popl %edx
@ -172,29 +172,47 @@ __ZN7_cygtls6lockedEv:
movl $tls::pstacklock(%eax),%eax movl $tls::pstacklock(%eax),%eax
ret ret
.extern __ZN7_cygtls19call_signal_handlerEv
stabilize_sig_stack:
1: movl %fs:4,%edx
movl \$1,%eax
lock xchgl %eax,$tls::stacklock(%edx)
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
orl %eax,%eax
jz 2f
xorl %eax,%eax
call _low_priority_sleep
jmp 1b
2: cmpl \$0,$tls::sig(%edx)
jz 3f
decl $tls::stacklock(%edx) # unlock
movl \$-$tls::sizeof__cygtls,%eax # point to beginning
addl %edx,%eax # of tls block
call __ZN7_cygtls19call_signal_handlerEv
jmp 1b
3: ret
.global _sigreturn .global _sigreturn
.stabs "sigreturn:F(0,1)",36,0,0,_sigreturn .stabs "sigreturn:F(0,1)",36,0,0,_sigreturn
_sigreturn: _sigreturn:
addl \$4,%esp # Remove argument addl \$4,%esp # Remove argument
call _set_process_mask\@4 call _set_process_mask\@4
movl %fs:4,%ebx call stabilize_sig_stack
# cmpl \$0,$tls::sig(%ebx) # Did a signal come in? 1: popl %ebx # saved errno
# jnz 3f # Yes, if non-zero testl %ebx,%ebx # Is it < 0
jl 2f # yup. ignore it
1: popl %edx # saved errno movl $tls::errno_addr(%edx),%eax
testl %edx,%edx # Is it < 0 movl %ebx,(%eax)
jl 2f # yup. ignore it
movl $tls::errno_addr(%ebx),%eax
movl %edx,(%eax)
2: popl %eax 2: popl %eax
popl %ebx popl %ebx
popl %ecx popl %ecx
popl %edx
popl %edi popl %edi
popl %esi popl %esi
popf popf
decl $tls::stacklock(%edx) # relinquish lock
popl %edx
popl %ebp popl %ebp
jmp __sigbe jmp __sigbe
@ -203,10 +221,10 @@ _sigreturn:
_sigdelayed: _sigdelayed:
pushl %ebp pushl %ebp
movl %esp,%ebp movl %esp,%ebp
pushl %edx
pushf pushf
pushl %esi pushl %esi
pushl %edi pushl %edi
pushl %edx
pushl %ecx pushl %ecx
pushl %ebx pushl %ebx
pushl %eax pushl %eax
@ -236,26 +254,6 @@ EOF
sub longjmp { sub longjmp {
return <<EOF; return <<EOF;
.extern __ZN7_cygtls19call_signal_handlerEv
stabilize_sig_stack:
1: movl %fs:4,%edx
movl \$1,%eax
lock xchgl %eax,$tls::stacklock(%edx)
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
orl %eax,%eax
jz 2f
xorl %eax,%eax
call _low_priority_sleep
jmp 1b
2: cmpl \$0,$tls::sig(%edx)
jz 3f
decl $tls::stacklock(%edx) # unlock
movl \$-$tls::sizeof__cygtls,%eax # point to beginning
addl %edx,%eax # of tls block
call __ZN7_cygtls19call_signal_handlerEv
jmp 1b
3: ret
.globl _setjmp .globl _setjmp
_setjmp: _setjmp:
pushl %ebp pushl %ebp

View File

@ -255,15 +255,20 @@ malloc_init ()
new_muto (mallock); new_muto (mallock);
#ifndef MALLOC_DEBUG #ifndef MALLOC_DEBUG
/* Check if mallock is provided by application. If so, redirect all /* Check if malloc is provided by application. If so, redirect all
calls to malloc/free/realloc to application provided. This may calls to malloc/free/realloc to application provided. This may
happen if some other dll calls cygwin's malloc, but main code provides happen if some other dll calls cygwin's malloc, but main code provides
its own malloc */ its own malloc */
if (!user_data->forkee) if (!user_data->forkee)
{ {
user_data->free (user_data->malloc (16)); user_data->free (user_data->malloc (16));
if (!export_malloc_called) if (export_malloc_called)
use_internal_malloc = 0; malloc_printf ("using internal malloc");
else
{
use_internal_malloc = 0;
malloc_printf ("using external malloc");
}
} }
#endif #endif
} }

View File

@ -72,7 +72,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
w->options = options; w->options = options;
w->rusage = r; w->rusage = r;
sigproc_printf ("calling proc_subproc, pid %d, options %d", sigproc_printf ("calling proc_subproc, pid %d, options %d",
w->pid, w->options); w->pid, w->options);
if (!proc_subproc (PROC_WAIT, (DWORD) w)) if (!proc_subproc (PROC_WAIT, (DWORD) w))
{ {
set_errno (ENOSYS); set_errno (ENOSYS);