mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 06:45:56 +08:00
Avoid undefined behavior in Guile exception handling
The Guile code will longjmp (via scm_throw) when an object requiring destruction is on the stack. This is undefined behavior. This changes this code to run any destructors in inner scopes, and to pass a POD to gdbscm_throw_gdb_exception. gdb/ChangeLog 2019-04-25 Tom Tromey <tromey@adacore.com> * guile/scm-exception.c (gdbscm_scm_from_gdb_exception) (gdbscm_throw_gdb_exception): Take a gdbscm_gdb_exception. * guile/scm-block.c, guile/scm-breakpoint.c, guile/scm-cmd.c, guile/scm-disasm.c, guile/scm-frame.c, guile/scm-lazy-string.c, guile/scm-math.c, guile/scm-param.c, guile/scm-ports.c, guile/scm-symbol.c, guile/scm-symtab.c, guile/scm-type.c, guile/scm-value.c: Use unpack. * guile/guile-internal.h (gdbscm_scm_from_gdb_exception): Take a gdbscm_gdb_exception. (gdbscm_throw_gdb_exception): Likewise. (struct gdbscm_gdb_exception): New. (unpack): New function. (gdbscm_wrap): Use unpack.
This commit is contained in:
@ -247,6 +247,7 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest)
|
||||
int insn_len = 0;
|
||||
string_file buf;
|
||||
|
||||
gdbscm_gdb_exception exc {};
|
||||
try
|
||||
{
|
||||
if (using_port)
|
||||
@ -259,9 +260,10 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest)
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
GDBSCM_HANDLE_GDB_EXCEPTION (except);
|
||||
exc = unpack (except);
|
||||
}
|
||||
|
||||
GDBSCM_HANDLE_GDB_EXCEPTION (exc);
|
||||
result = scm_cons (dascm_make_insn (pc, buf.c_str (), insn_len),
|
||||
result);
|
||||
|
||||
|
Reference in New Issue
Block a user