diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7ae7a4388..3bb4821cb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2004-03-03 Christopher Faylor + + * 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 * fhandler_raw.cc (fhandler_dev_raw::raw_read): When reading with diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 94163fd52..45d840aee 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1200,4 +1200,5 @@ reset_signal_arrived () { (void) ResetEvent (signal_arrived); sigproc_printf ("reset signal_arrived"); +if (_my_tls.stackptr > _my_tls.stack) debug_printf ("stackptr[-1] %p", _my_tls.stackptr[-1]); } diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef index 14c9f6702..141a4e77e 100755 --- a/winsup/cygwin/gendef +++ b/winsup/cygwin/gendef @@ -128,8 +128,8 @@ __sigbe: 2: movl \$-4,%eax # now decrement aux stack xadd %eax,$tls::stackptr(%edx) # and get pointer xorl %ebx,%ebx - xchgl %ebx,-4(%eax) # - xchgl %ebx,8(%esp) + xchgl %ebx,-4(%eax) # get return address from signal stack + xchgl %ebx,8(%esp) # restore ebx/real return address decl $tls::stacklock(%edx) # release lock popl %eax popl %edx @@ -172,29 +172,47 @@ __ZN7_cygtls6lockedEv: movl $tls::pstacklock(%eax),%eax 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 .stabs "sigreturn:F(0,1)",36,0,0,_sigreturn _sigreturn: - addl \$4,%esp # Remove argument + addl \$4,%esp # Remove argument call _set_process_mask\@4 - movl %fs:4,%ebx + call stabilize_sig_stack -# cmpl \$0,$tls::sig(%ebx) # Did a signal come in? -# jnz 3f # Yes, if non-zero - -1: popl %edx # saved errno - testl %edx,%edx # Is it < 0 - jl 2f # yup. ignore it - movl $tls::errno_addr(%ebx),%eax - movl %edx,(%eax) +1: popl %ebx # saved errno + testl %ebx,%ebx # Is it < 0 + jl 2f # yup. ignore it + movl $tls::errno_addr(%edx),%eax + movl %ebx,(%eax) 2: popl %eax popl %ebx popl %ecx - popl %edx popl %edi popl %esi popf + decl $tls::stacklock(%edx) # relinquish lock + popl %edx popl %ebp jmp __sigbe @@ -203,10 +221,10 @@ _sigreturn: _sigdelayed: pushl %ebp movl %esp,%ebp + pushl %edx pushf pushl %esi pushl %edi - pushl %edx pushl %ecx pushl %ebx pushl %eax @@ -236,26 +254,6 @@ EOF sub longjmp { return <forkee) { user_data->free (user_data->malloc (16)); - if (!export_malloc_called) - use_internal_malloc = 0; + if (export_malloc_called) + malloc_printf ("using internal malloc"); + else + { + use_internal_malloc = 0; + malloc_printf ("using external malloc"); + } } #endif } diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc index d92a32911..789a7f309 100644 --- a/winsup/cygwin/wait.cc +++ b/winsup/cygwin/wait.cc @@ -72,7 +72,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r) w->options = options; w->rusage = r; sigproc_printf ("calling proc_subproc, pid %d, options %d", - w->pid, w->options); + w->pid, w->options); if (!proc_subproc (PROC_WAIT, (DWORD) w)) { set_errno (ENOSYS);