public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Vrany <jan.vrany@fit.cvut.cz>
To: gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: Re: [PATCH v3] Fix segfault when invoking -var-info-path-expression on a dynamic varobj
Date: Thu, 28 Jun 2018 16:19:00 -0000	[thread overview]
Message-ID: <8ef6ce659b588fd1370447b7e6da1e614b3c2b75.camel@fit.cvut.cz> (raw)
In-Reply-To: <b7c4e8fd-c8a8-7649-b257-dc5e6e872b4b@ericsson.com>

On Thu, 2018-06-28 at 12:03 -0400, Simon Marchi wrote:
> 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?

Hi Simon, 

yes, it passes on my machine. 

> 
> $ 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"

Uff, I think I know what's the problem, Python 3.x vs Python 2.x.
My GDB is compiled with 3.x and - I guess - yours is with Python 2.x. 

I'll fix the python code to work on both later today. Sorry about it. 

Jan



      reply	other threads:[~2018-06-28 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28 15:19 Jan Vrany
2018-06-28 16:03 ` Simon Marchi
2018-06-28 16:19   ` Jan Vrany [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ef6ce659b588fd1370447b7e6da1e614b3c2b75.camel@fit.cvut.cz \
    --to=jan.vrany@fit.cvut.cz \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).