diff options
author | Joel Brobecker <brobecker@adacore.com> | 2013-10-29 11:36:58 +0100 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2013-12-03 15:42:48 +0400 |
commit | 849f2b52ec2b71bc76188ac8c53f35fb57a5d41c (patch) | |
tree | c9755759006fe51f398edddc25258107dd33152d /gdb | |
parent | 4e35e8085e8922746e0731a7005452de499620fa (diff) | |
download | gdb-849f2b52ec2b71bc76188ac8c53f35fb57a5d41c.zip gdb-849f2b52ec2b71bc76188ac8c53f35fb57a5d41c.tar.gz gdb-849f2b52ec2b71bc76188ac8c53f35fb57a5d41c.tar.bz2 |
crash evaluating bogus exception condition expression (sparc-solaris)
With a program raising an exception, trying to debug that program
in GDB/MI mode can yield a crash:
% gdb -i=mi foo
(gdb)
-catch-exception -e "Program_Error"
^done,bkptno="2",bkpt={number="2",type="breakpoint",[...]
(gdb)
-exec-continue
^running
*running,thread-id="all"
(gdb)
=library-loaded,id=[...]
&"warning: failed to reevaluate internal exception condition for catchpoint 2: Error in expression, near `'.\n"
zsh: 22956 bus error (core dumped) gdb -q -i=mi foo
The problem is triggered by a problem in the compiler which causes
EXP in the following TRY_CATCH block to change unexpectedly when
parse_exp_1 throws an error :
| TRY_CATCH (e, RETURN_MASK_ERROR)
| {
| exp = parse_exp_1 (&s, bl->address,
| block_for_pc (bl->address), 0);
| }
In ada-lang.c:create_excep_cond_exprs, EXP is initialized to NULL,
and is expected to remain NULL if parse_exp_1 throws. Instead,
its value gets changed to something invalid. This later crashes
the debugger, when trying to evaluate the bogus expression.
This patch works around the issue by simply forcing EXP back to NULL
when an exception was thrown. A comment explaining why, and the sort
of timeline we're looking at for a fix, is also added.
gdb/ChangeLog:
* ada-lang.c (create_excep_cond_exprs): Force EXP to NULL
when parse_exp_1 threw an error. Add comment.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a7eb64d..6e4b9a5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2013-12-03 Joel Brobecker <brobecker@adacore.com> + * ada-lang.c (create_excep_cond_exprs): Force EXP to NULL + when parse_exp_1 threw an error. Add comment. + +2013-12-03 Joel Brobecker <brobecker@adacore.com> + * NEWS: Mention "-list-features" in the entry documenting the support for the "--language" option. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 417232c..786ca7a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11461,9 +11461,18 @@ create_excep_cond_exprs (struct ada_catchpoint *c) block_for_pc (bl->address), 0); } if (e.reason < 0) - warning (_("failed to reevaluate internal exception condition " - "for catchpoint %d: %s"), - c->base.number, e.message); + { + warning (_("failed to reevaluate internal exception condition " + "for catchpoint %d: %s"), + c->base.number, e.message); + /* There is a bug in GCC on sparc-solaris when building with + optimization which causes EXP to change unexpectedly + (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56982). + The problem should be fixed starting with GCC 4.9. + In the meantime, work around it by forcing EXP back + to NULL. */ + exp = NULL; + } } ada_loc->excep_cond_expr = exp; |