* 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.
This commit is contained in:
Christopher Faylor 2008-03-02 22:51:19 +00:00
parent 1264c4d4fa
commit 6452eb1f2a
5 changed files with 46 additions and 12 deletions

View File

@ -1,3 +1,19 @@
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

View File

@ -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;
el.prev = NULL;
}

View File

@ -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;
}

View File

@ -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));

View File

@ -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