[PATCH v3] Fix segfault when invoking -var-info-path-expression on a dynamic varobj
Simon Marchi
simon.marchi@ericsson.com
Thu Jun 28 16:03:00 GMT 2018
On 2018-06-28 11:17 AM, Jan Vrany wrote:
> Invoking -var-info-path-expression on a dynamic varobj lead either in wrong
> (nonsense) result or to a segmentation fault in cplus_describe_child().
> This was caused by the fact that varobj_get_path_expr() called
> cplus_path_expr_of_child() ignoring the fact the parent of the variable
> is dynamic. Then, cplus_describe_child() accessed the underlaying C type
> members by index, causing (i) either wrong (nonsense) expression being
> returned (since dynamic child may be completely arbibtrary value)
> or (ii) segmentation fault (in case the index higher than number of
> underlaying C type members.
>
> This fixes the problem by checking whether a varobj is a child of a dynamic
> varobj and, if so, reporting an error as described in documentation.
Hi Jan,
Thanks, this builds fine now. The test doesn't pass here though. Does it
pass on your side?
$ make check TESTS="gdb.python/py-mi-var-info-path-expression.exp"
...
FAIL: gdb.python/py-mi-var-info-path-expression.exp: -var-create c1 * &c1 (unexpected output)
FAIL: gdb.python/py-mi-var-info-path-expression.exp: -var-list-children c1 (unexpected output)
FAIL: gdb.python/py-mi-var-info-path-expression.exp: -var-list-children c1.cdr (unexpected output)
FAIL: gdb.python/py-mi-var-info-path-expression.exp: -var-list-children c1.car (unexpected output)
FAIL: gdb.python/py-mi-var-info-path-expression.exp: -var-list-children c1.car.atom (unexpected output)
I'm seeing some Python exception in testsuite/gdb.log, I didn't dig more than that:
-var-create c1 * &c1
&"Traceback (most recent call last):\n"
&" File \"/home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py\", line 24, in to_string\n"
&" if int(self._val) == 0:\n"
&"gdb.error: Cannot convert value to int.\n"
&"Traceback (most recent call last):\n"
&" File \"/home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py\", line 32, in children\n"
&" if int(self._val) == 0:\n"
&"gdb.error: Cannot convert value to int.\n"
^error,msg="Null value returned for children"
(gdb)
FAIL: gdb.python/py-mi-var-info-path-expression.exp: -var-create c1 * &c1 (unexpected output)
Simon
More information about the Gdb-patches
mailing list