This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Avoid undefined behavior in ada_operator_length
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Wed, 03 Oct 2018 19:29:11 -0400
- Subject: [binutils-gdb] Avoid undefined behavior in ada_operator_length
*** TEST RESULTS FOR COMMIT 5e70ee0905a848701bb929a66f84ff2e212cfa81 ***
Author: Tom Tromey <tom@tromey.com>
Branch: master
Commit: 5e70ee0905a848701bb929a66f84ff2e212cfa81
Avoid undefined behavior in ada_operator_length
-fsanitize=undefined pointed out this error:
runtime error: load of value 2887952, which is not a valid value for type 'exp_opcode'
This happens in gdb.ada/complete.exp when processing "complete p
my_glob". This does not parse, so the Ada parser throws an exception;
but then the code in parse_exp_in_context_1 accepts the expression
anyway. However, as no elements have been written to the expression,
undefined behavior results.
The fix is to notice this case in parse_exp_in_context_1. This patch
also adds an assertion to prefixify_expression to enforce this
pre-existing constraint.
gdb/ChangeLog
2018-10-03 Tom Tromey <tom@tromey.com>
* parse.c (prefixify_expression): Add assert.
(parse_exp_in_context_1): Throw exception if the expression is
empty.