public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix C++ exceptions across readline result in std::terminate() -> SIGABRT
@ 2016-04-21 23:50 Pedro Alves
  2016-04-21 23:50 ` [PATCH 2/3] Propagate GDB/C++ exceptions across readline using sj/lj-based TRY/CATCH Pedro Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Pedro Alves @ 2016-04-21 23:50 UTC (permalink / raw)
  To: gdb-patches

We saw that if we map GDB'S TRY/CATCH macros to C++ try/catch, GDB
breaks on systems where readline isn't built with exceptions support.

Yao tripped on this on ARM/Fedora 19, and I saw the same thing on AIX.

The problem is that readline calls into GDB through the callback
interface, and if GDB's callback throws a C++ exception/error, the
system unwinder won't manage to unwind past the readline frame, and
ends up calling std::terminate(), which aborts the process:

 (gdb) whatever-command-that-causes-an-error
 terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
 Aborted
 $

This series:

 - stops GDB from throwing C++ exceptions across readline.

 - then flips back TRY/CATCH to C++ try/catch (which is necessary for
   automatically calling local variable destructors when
   throw_exception is called).

Tested on x86_64 Fedora, and confirmed that it fixes the issue on AIX.

Pedro Alves (3):
  Rename rl_callback_read_char_wrapper -> gdb_rl_callback_read_char
  Propagate GDB/C++ exceptions across readline using sj/lj-based
    TRY/CATCH
  Switch gdb's TRY/CATCH to C++ try/catch

 gdb/common/common-exceptions.h |  69 ++++++++++++++-----------
 gdb/common/common-exceptions.c |  38 +++++++++++---
 gdb/event-top.c                | 112 +++++++++++++++++++++++++++++++++++------
 3 files changed, 169 insertions(+), 50 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-04-22 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-21 23:50 [PATCH 0/3] Fix C++ exceptions across readline result in std::terminate() -> SIGABRT Pedro Alves
2016-04-21 23:50 ` [PATCH 2/3] Propagate GDB/C++ exceptions across readline using sj/lj-based TRY/CATCH Pedro Alves
2016-04-22  8:19   ` Yao Qi
2016-04-22  9:05     ` Pedro Alves
2016-04-22 15:25       ` Pedro Alves
2016-04-21 23:50 ` [PATCH 3/3] Switch gdb's TRY/CATCH to C++ try/catch Pedro Alves
2016-04-21 23:50 ` [PATCH 1/3] Rename rl_callback_read_char_wrapper -> gdb_rl_callback_read_char Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).