Mercurial > hg > xemacs-beta
changeset 4162:8f6a825eb3d3
[xemacs-hg @ 2007-09-04 21:20:18 by aidan]
Eliminate a crash when profiling; only pass the backtrace record to
profile_record_about_to_call, profile_record_just_called when it's non-nil.
author | aidan |
---|---|
date | Tue, 04 Sep 2007 21:20:26 +0000 |
parents | 08efedad2696 |
children | 75562ac25d7b |
files | src/ChangeLog src/eval.c src/profile.h |
diffstat | 3 files changed, 26 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Sep 03 21:51:09 2007 +0000 +++ b/src/ChangeLog Tue Sep 04 21:20:26 2007 +0000 @@ -1,3 +1,16 @@ +2006-11-26 Aidan Kehoe <kehoea@parhasard.net> + + * eval.c (Fcommand_execute): + * eval.c (Feval): + * eval.c (Ffuncall): + Use the PROFILE_DECLARE macro instead of declaring `struct + backtrace backtrace' by hand. + * profile.h: + * profile.h (PROFILE_EXIT_FUNCTION): + * profile.h (PROFILE_ENTER_FUNCTION): + Check do_backtrace before passing the backtrace structure to + profile_record_about_to_call, profile_record_just_called. + 2007-08-28 Aidan Kehoe <kehoea@parhasard.net> * mule-ccl.c (ccl_driver):
--- a/src/eval.c Mon Sep 03 21:51:09 2007 +0000 +++ b/src/eval.c Tue Sep 04 21:20:26 2007 +0000 @@ -3100,7 +3100,7 @@ /* This function can GC */ Lisp_Object prefixarg; Lisp_Object final = cmd; - struct backtrace backtrace; + PROFILE_DECLARE(); struct console *con = XCONSOLE (Vselected_console); prefixarg = con->prefix_arg; @@ -3533,7 +3533,7 @@ /* This function can GC */ Lisp_Object fun, val, original_fun, original_args; int nargs; - struct backtrace backtrace; + PROFILE_DECLARE(); #ifdef ERROR_CHECK_TRAPPING_PROBLEMS check_proper_critical_section_lisp_protection (); @@ -3841,7 +3841,7 @@ /* This function can GC */ Lisp_Object fun; Lisp_Object val; - struct backtrace backtrace; + PROFILE_DECLARE(); int fun_nargs = nargs - 1; Lisp_Object *fun_args = args + 1;
--- a/src/profile.h Mon Sep 03 21:51:09 2007 +0000 +++ b/src/profile.h Tue Sep 04 21:20:26 2007 +0000 @@ -47,11 +47,18 @@ This ensures correct behavior (e.g. we never modify the profiling info when profiling is not active) because we seed and reap all functions currently on the stack when starting and stopping. See - `start-profiling'. */ + `start-profiling'. + + We check do_backtrace to make sure that the backtrace structure is + initialised. If it isn't, we can enter a function with profiling turned + off, and exit it with it turned on, with the consequence that an + unitialised backtrace structure is passed to + profile_record_just_called. Since do_backtrace is function-local (apart + from in the garbage collector) this avoids that. */ #define PROFILE_ENTER_FUNCTION() \ do \ { \ - if (profiling_active) \ + if (profiling_active && do_backtrace) \ profile_record_about_to_call (&backtrace); \ } \ while (0) @@ -59,7 +66,7 @@ #define PROFILE_EXIT_FUNCTION() \ do \ { \ - if (profiling_active) \ + if (profiling_active && do_backtrace) \ profile_record_just_called (&backtrace); \ } \ while (0)