From 7279d9814f98320c3be5f56136bf27510961eb2e Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Fri, 13 Mar 2009 01:29:19 +0100 Subject: [PATCH] Don't risk hanging on mutexes when threads are disabled in Pike_fatal. Rev: src/error.c:1.167 --- src/error.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/error.c b/src/error.c index 1af328c4c2..621ab0d3be 100644 --- a/src/error.c +++ b/src/error.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: error.c,v 1.166 2008/10/04 17:19:05 mast Exp $ +|| $Id: error.c,v 1.167 2009/03/13 00:29:19 mast Exp $ */ #define NO_PIKE_SHORTHAND @@ -619,9 +619,11 @@ PMOD_EXPORT DECLSPEC(noreturn) void debug_va_fatal(const char *fmt, va_list args { JMP_BUF jmp; struct callback_list saved_eval_cbs = evaluator_callbacks; - /* Don't want thread switches or any other evaluator stuff while - * we let the master describe the backtrace below. */ - low_init_threads_disable(); + /* Simulate threads_disabled to avoid thread switches or any other + * evaluator stuff while we let the master describe the backtrace + * below. Doing it the naughty way without going through + * init_threads_disable etc to avoid hanging on runaway locks. */ + threads_disabled++; MEMSET (&evaluator_callbacks, 0, sizeof (evaluator_callbacks)); if (SETJMP (jmp)) fprintf(stderr,"Got exception when trying to describe backtrace.\n"); @@ -633,7 +635,7 @@ PMOD_EXPORT DECLSPEC(noreturn) void debug_va_fatal(const char *fmt, va_list args write_to_stderr(Pike_sp[-1].u.string->str, Pike_sp[-1].u.string->len); } UNSETJMP (jmp); - exit_threads_disable (NULL); + threads_disabled--; evaluator_callbacks = saved_eval_cbs; }else{ fprintf(stderr,"No stack - no backtrace.\n"); -- GitLab