[PATCH 1/1] gdb: add check for empty array
Tom Tromey
tom@tromey.com
Tue Dec 17 14:39:33 GMT 2024
>>>>> "Piotr" == Piotr Rudnicki <piotr.rudnicki@intel.com> writes:
Piotr> With the command before the change, gdb crashes with message:
Piotr> (gdb) p 1 == { }
Piotr> Fatal signal: Segmentation fault
Where does the crash occur?
Piotr> Add a new test file gdb.base/array-value/exp to test this change.
Thank you.
Piotr> diff --git a/gdb/valops.c b/gdb/valops.c
Piotr> index 88a42d38660..9e4fe2844d2 100644
Piotr> --- a/gdb/valops.c
Piotr> +++ b/gdb/valops.c
Piotr> @@ -1695,6 +1695,9 @@ value_array (int lowbound, gdb::array_view<struct value *> elemvec)
Piotr> /* Validate that the bounds are reasonable and that each of the
Piotr> elements have the same size. */
Piotr> + if (elemvec.empty ())
Piotr> + error (_("array must not be empty"));
I don't have an issue with the patch itself but I wonder if it's correct
to always disallow arrays with 0 length. For instance, I think they are
valid in Rust.
FWIW I can reproduce in Rust:
set lang rust
print [0;0]
Anyway my question is whether this can be fixed to instead allow a
0-length array.
Tom
More information about the Gdb-patches
mailing list