From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130752 invoked by alias); 28 Jun 2018 16:19:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 130735 invoked by uid 89); 28 Jun 2018 16:19:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: relay.fit.cvut.cz Received: from relay.fit.cvut.cz (HELO relay.fit.cvut.cz) (147.32.232.237) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Jun 2018 16:19:09 +0000 Received: from imap.fit.cvut.cz (imap.fit.cvut.cz [IPv6:2001:718:2:2901:0:0:0:238] (may be forged)) by relay.fit.cvut.cz (8.15.2/8.15.2) with ESMTPS id w5SGJ37M015276 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK); Thu, 28 Jun 2018 18:19:05 +0200 (CEST) (envelope-from jan.vrany@fit.cvut.cz) Received: from sao (0279192e.bb.sky.com [2.121.25.46] (may be forged)) (authenticated bits=0 as user vranyj1) by imap.fit.cvut.cz (8.15.2/8.15.2) with ESMTPSA id w5SGJ2tW044499 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 28 Jun 2018 18:19:03 +0200 (CEST) (envelope-from jan.vrany@fit.cvut.cz) Message-ID: <8ef6ce659b588fd1370447b7e6da1e614b3c2b75.camel@fit.cvut.cz> Subject: Re: [PATCH v3] Fix segfault when invoking -var-info-path-expression on a dynamic varobj From: Jan Vrany To: gdb-patches Cc: Simon Marchi Date: Thu, 28 Jun 2018 16:19:00 -0000 In-Reply-To: References: <20180628151736.21681-1-jan.vrany@fit.cvut.cz> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00689.txt.bz2 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