From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Hui Zhu <teawater@gmail.com>
Cc: Tom Tromey <tromey@redhat.com>,
gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [PATCH] printcmd.c (ui_printf): make internalvar string can be printf and eval when inferior cannot alloc memory
Date: Tue, 06 Sep 2011 13:44:00 -0000 [thread overview]
Message-ID: <20110906085007.GA19880@host1.jankratochvil.net> (raw)
In-Reply-To: <CANFwon0=Trk5i-j4MRPOAXx0AeJaqsZk6Tg052n9_EUEiQ=LrQ@mail.gmail.com>
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
next prev parent reply other threads:[~2011-09-06 8:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 10:37 Hui Zhu
2011-07-21 20:43 ` Tom Tromey
2011-08-14 15:10 ` Hui Zhu
2011-08-15 19:06 ` Tom Tromey
2011-08-16 4:58 ` Hui Zhu
2011-08-17 14:38 ` Tom Tromey
2011-08-18 2:54 ` Hui Zhu
2011-08-19 14:15 ` Tom Tromey
2011-09-06 8:50 ` Hui Zhu
2011-09-06 13:44 ` Jan Kratochvil [this message]
2011-09-07 9:27 ` Hui Zhu
2011-09-07 10:02 ` Jan Kratochvil
2011-09-09 7:59 ` Hui Zhu
2011-09-09 12:32 ` Jan Kratochvil
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=20110906085007.GA19880@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=teawater@gmail.com \
--cc=tromey@redhat.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