diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 16 | ||||
-rw-r--r-- | winsup/cygwin/cygtls.cc | 14 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 24 | ||||
-rw-r--r-- | winsup/cygwin/strfuncs.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/winsup.h | 2 |
5 files changed, 46 insertions, 12 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7dfdc0272..344ae6d55 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,21 @@ 2008-03-02 Christopher Faylor <me+cygwin@cgf.cx> + * 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. + +2008-03-02 Christopher Faylor <me+cygwin@cgf.cx> + * smallprint.cc (__small_vsprintf): Free allocated buffer rather than pointer into the buffer. diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index bb6e5a643..0370d06e8 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -246,6 +246,18 @@ _cygtls::init_exception_handler (exception_handler *eh) Windows 2008, which irremediably gets into an endless loop, taking 100% CPU. That's why we reverted to a normal SEH chain and changed the way the exception handler returns to the application. */ - el.prev = _except_list; + /* 2008-03-28 - The fun continues. Revert to doing something sorta like + before. Just make sure *only* the cygwin exception handler is installed + rather than honoring other exception handlers. The theory here is that + cygwin should be in control and there should be no Windows voodoo going + on behind the scenes. + + This change was made so that this function could be called from + handle_exceptions to essentially "clean up" the exception handling + linked list. + + The open question is whether making this NULL will have an adverse effect + on Windows functions. */ _except_list = ⪙ + el.prev = NULL; } 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; } diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index d353fd868..f0623dfa6 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -67,7 +67,7 @@ sys_wcstombs_alloc (char **tgt_p, int type, const PWCHAR src, int slen) ret = WideCharToMultiByte (get_cp (), 0, src, slen, NULL, 0 ,NULL, NULL); if (ret) { - size_t tlen = (slen == -1 ? ret : ret + 1); + size_t tlen = (slen == -1) ? ret : ret + 1; if (type == HEAP_NOTHEAP) *tgt_p = (char *) calloc (tlen, sizeof (char)); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 0ff83f354..957cc38fd 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -149,7 +149,7 @@ extern int dynamically_loaded; extern int cygserver_running; -#define _MT_SAFE // DELTEME someday +#define _MT_SAFE // DELETEME someday #define TITLESIZE 1024 |