Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2008-03-03 01:51:19 +0300
committerChristopher Faylor <me@cgf.cx>2008-03-03 01:51:19 +0300
commit6452eb1f2a1f04e8336b94f822f5f2710922ef33 (patch)
tree861144b78685b5103e8ff1fdcce3ecb6dba127f7 /winsup/cygwin/exceptions.cc
parent1264c4d4fa45be3ab77e8d384012312a53528ca7 (diff)
* cygtls.cc (_cygtls::init_exception_handler): Semi-revert to making only
ourselves the exception handler and nothing else. * exceptions.cc (open_stackdumpfile): Use correct format specifiers for unicode when printing nameof stackdump file. (stack_info::walk): Stop walking if ebp points into cygwin itself. (_cygtls::handle_exceptions): Detect when signal is masked and treat as if it was not caught. Reinitialize exception handler to known state to avoid subsequent attempts to call Windows exception handlers if an exception occurs in a signal handler. Revert to a 'return 0' rather than using a goto. * strfuncs.cc (sys_wcstombs_alloc): Minor formatting tweak. * winsup.h: Fix comment typo.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r--winsup/cygwin/exceptions.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 56f191851..71c15d5f7 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1,7 +1,7 @@
/* exceptions.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Red Hat, Inc.
+ 2005, 2006, 2007, 2008 Red Hat, Inc.
This file is part of Cygwin.
@@ -168,9 +168,9 @@ open_stackdumpfile ()
if (NT_SUCCESS (status))
{
if (!myself->cygstarted)
- system_printf ("Dumping stack trace to %s", corefile);
+ system_printf ("Dumping stack trace to %S", &ucore);
else
- debug_printf ("Dumping stack trace to %s", corefile);
+ debug_printf ("Dumping stack trace to %S", &ucore);
SetStdHandle (STD_ERROR_HANDLE, h);
}
}
@@ -253,7 +253,7 @@ int
stack_info::walk ()
{
char **ebp;
- if ((ebp = (char **) next_offset ()) == NULL)
+ if (((ebp = (char **) next_offset ()) == NULL) || (ebp >= (char **) cygwin_hmodule))
return 0;
sf.AddrFrame.Offset = (DWORD) ebp;
@@ -602,7 +602,8 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
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);
- if (global_sigs[si.si_signo].sa_mask & SIGTOMASK (si.si_signo))
+ bool masked = !!(me.sigmask & SIGTOMASK (si.si_signo));
+ if (masked)
syscall_printf ("signal %d, masked %p", si.si_signo,
global_sigs[si.si_signo].sa_mask);
@@ -621,12 +622,19 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
me.return_from_fault ();
me.copy_context (in);
- if (!cygwin_finished_initializing
+
+ /* Reinitialize exception handler list to include just ourselves so that any
+ exceptions that occur in a signal handler will be properly caught. */
+ me.init_exception_handler (handle_exceptions);
+
+ if (masked
|| &me == _sig_tls
+ || !cygwin_finished_initializing
|| (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_DFL
|| (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_IGN
|| (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_ERR)
{
+ rtl_unwind (frame, e);
/* Print the exception to the console */
if (!myself->cygstarted)
for (int i = 0; status_info[i].name; i++)
@@ -645,10 +653,9 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
if (try_to_debug (0))
{
debugging = true;
- goto out;
+ return 0;
}
- rtl_unwind (frame, e);
open_stackdumpfile ();
exception (e, in);
stackdump ((DWORD) ebp, 0, 1);
@@ -679,7 +686,6 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
sig_send (NULL, si, &me); // Signal myself
me.incyg--;
e->ExceptionFlags = 0;
-out:
return 0;
}