From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17932 invoked by alias); 6 Sep 2011 08:50:29 -0000 Received: (qmail 17920 invoked by uid 22791); 6 Sep 2011 08:50:27 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_RV,TW_TR,TW_VF,TW_XZ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Sep 2011 08:50:12 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p868oCZI007315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Sep 2011 04:50:12 -0400 Received: from host1.jankratochvil.net (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p868oAmF024639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 6 Sep 2011 04:50:11 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p868o9Jm023969; Tue, 6 Sep 2011 10:50:09 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p868o8Ug023964; Tue, 6 Sep 2011 10:50:08 +0200 Date: Tue, 06 Sep 2011 13:44:00 -0000 From: Jan Kratochvil To: Hui Zhu Cc: Tom Tromey , gdb-patches ml Subject: Re: [PATCH] printcmd.c (ui_printf): make internalvar string can be printf and eval when inferior cannot alloc memory Message-ID: <20110906085007.GA19880@host1.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-09/txt/msg00085.txt.bz2 On Tue, 06 Sep 2011 10:21:53 +0200, Hui Zhu wrote: > + if (TYPE_CODE (check_typedef (value_type (val_args[i]))) > + == TYPE_CODE_ARRAY) > + fprintf_filtered (stream, current_substring, > + (char *) value_contents (val_args[i])); (gdb) set $a={'a','b'} (gdb) printf "%s\n",$a ==23392== Invalid read of size 1 ==23392== at: vfprintf (vfprintf.c:1568) ==23392== by: vasprintf (vasprintf.c:64) ==23392== by: xstrvprintf (common-utils.c:131) ==23392== by: vfprintf_maybe_filtered (utils.c:2379) ==23392== by: vfprintf_filtered (utils.c:2389) ==23392== by: fprintf_filtered (utils.c:2441) ==23392== by: ui_printf (printcmd.c:2348) [...] ==23392== Address 0xd24bb82 is 0 bytes after a block of size 2 alloc'd ==23392== at: calloc (vg_replace_malloc.c:467) ==23392== by: xcalloc (common-utils.c:92) ==23392== by: xzalloc (common-utils.c:102) ==23392== by: allocate_value_contents (value.c:690) ==23392== by: allocate_value (value.c:700) ==23392== by: value_copy (value.c:1299) ==23392== by: value_of_internalvar (value.c:1725) ==23392== by: evaluate_subexp_standard (eval.c:903) ==23392== by: evaluate_subexp_c (c-lang.c:720) ==23392== by: evaluate_subexp (eval.c:76) ==23392== by: evaluate_expression (eval.c:151) ==23392== by: parse_to_comma_and_eval (eval.c:136) ==23392== by: ui_printf (printcmd.c:2328) [...] The original code was not completely correct in such cases but GDB could not crash, now it can, I find it as a regression. I would welcome a testcase. Thanks, Jan