]> git.eshelyaron.com Git - emacs.git/commit
eval_sub followed dangling pointer when debugging
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 17 Nov 2015 07:08:54 +0000 (23:08 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 17 Nov 2015 07:09:28 +0000 (23:09 -0800)
commit54beeef1180e5ff2adb6797b6b4572e71c882e95
treebe939c06ccdeac25775f22790a2c83d7fd0eeaf0
parent1721600d2463bacd13faa2c7613b7897a84d1099
eval_sub followed dangling pointer when debugging

Problem reported by Pip Cet (Bug#21245).
This bug could occur in eval_sub if the C compiler reused
storage associated with the ‘argvals’ local after ‘argvals’
went out of scope, and if the Elisp debugger stopped on Elisp
function exit and accessed ‘argvals’.  It could also occur if
a variadic function was called with so many arguments (over
2048 args on x86-64) that SAFE_ALLOCA_LISP called malloc, then
SAFE_FREE freed the arguments, then the memory manager used
the storage for other purposes, then the debugger accessed the
arguments.
* src/eval.c (eval_sub): Declare ‘argvals’ at top level of
function body. Simplify local decls.
When allocating args via SAFE_ALLOCA, call
debugger before invoking SAFE_FREE, as the debugger needs
access to the args.
(eval_sub, apply_lambda): Rework to avoid need for
set_backtrace_debug_on_exit hack.  This is cleaner,
and should work better with buggy custom debuggers.
src/eval.c