mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
Fix abort_to_prompt bug if dynwind leave thunk expands the stack
* libguile/vm.c (scm_i_vm_emergency_abort, abort_to_prompt): Unwinding the dynwind stack can run dynwind leave thunks, which may expand the stack, which may invalidate previously calculated SP / FP values. (Re)calculate SP/FP after unwinding, to avoid writing to unmapped memory. Fixes compile errors seen on Ubuntu and some other ports.
This commit is contained in:
parent
76e436c892
commit
e3e3e691f8
1 changed files with 8 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2001,2009-2015,2017-2019
|
/* Copyright 2001,2009-2015,2017-2020
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Guile.
|
This file is part of Guile.
|
||||||
|
@ -1360,9 +1360,6 @@ scm_i_vm_emergency_abort (SCM *tag_and_argv, size_t n)
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = vp->stack_top - fp_offset;
|
|
||||||
sp = vp->stack_top - sp_offset;
|
|
||||||
|
|
||||||
if (!(flags & SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY))
|
if (!(flags & SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "guile: fatal: emergency abort to non-linear prompt\n");
|
fprintf (stderr, "guile: fatal: emergency abort to non-linear prompt\n");
|
||||||
|
@ -1374,6 +1371,9 @@ scm_i_vm_emergency_abort (SCM *tag_and_argv, size_t n)
|
||||||
/* Unwind. */
|
/* Unwind. */
|
||||||
scm_dynstack_unwind (dynstack, prompt);
|
scm_dynstack_unwind (dynstack, prompt);
|
||||||
|
|
||||||
|
fp = vp->stack_top - fp_offset;
|
||||||
|
sp = vp->stack_top - sp_offset;
|
||||||
|
|
||||||
/* Continuation gets nargs+1 values: the one more is for the cont. */
|
/* Continuation gets nargs+1 values: the one more is for the cont. */
|
||||||
sp = sp - nargs - 1;
|
sp = sp - nargs - 1;
|
||||||
|
|
||||||
|
@ -1422,7 +1422,6 @@ abort_to_prompt (scm_thread *thread, uint8_t *saved_mra)
|
||||||
scm_misc_error ("abort", "Abort to unknown prompt", scm_list_1 (tag));
|
scm_misc_error ("abort", "Abort to unknown prompt", scm_list_1 (tag));
|
||||||
|
|
||||||
fp = vp->stack_top - fp_offset;
|
fp = vp->stack_top - fp_offset;
|
||||||
sp = vp->stack_top - sp_offset;
|
|
||||||
|
|
||||||
/* Only reify if the continuation referenced in the handler. */
|
/* Only reify if the continuation referenced in the handler. */
|
||||||
if (flags & SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY)
|
if (flags & SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY)
|
||||||
|
@ -1439,6 +1438,10 @@ abort_to_prompt (scm_thread *thread, uint8_t *saved_mra)
|
||||||
/* Unwind. */
|
/* Unwind. */
|
||||||
scm_dynstack_unwind (dynstack, prompt);
|
scm_dynstack_unwind (dynstack, prompt);
|
||||||
|
|
||||||
|
/* Recompute FP, as scm_dynstack_unwind may have expanded the stack. */
|
||||||
|
fp = vp->stack_top - fp_offset;
|
||||||
|
sp = vp->stack_top - sp_offset;
|
||||||
|
|
||||||
/* Continuation gets nargs+1 values: the one more is for the cont. */
|
/* Continuation gets nargs+1 values: the one more is for the cont. */
|
||||||
sp = sp - nargs - 1;
|
sp = sp - nargs - 1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue