From: Tom Tromey <tromey@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: fix `gdb -write' case
Date: Mon, 09 May 2011 14:54:00 -0000 [thread overview]
Message-ID: <m3wri0sz65.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4DC75B31.2020501@codesourcery.com> (Yao Qi's message of "Mon, 09 May 2011 11:10:41 +0800")
>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
Tom> https://bugzilla.redhat.com/show_bug.cgi?id=696148
Yao> FYI, I can't access this bug. I am told "You are not authorized to
Yao> access bug #696148."
Oops, sorry. It is a private bug -- not for any good reason AFAICT, but
I can't change it.
Here is Jan's one-line reproducer:
echo 'char s[]="a";main(){return s[0]=='"'a';}"|gcc -o v -x c - -g;./v;echo $?;~/redhat/gdb-6.8/gdb/gdb -nx -write ./v -ex 'set var s="b"' -ex q;./v;echo $?
Tom> + result = allocate_value (expect_type);
Tom> + memcpy (value_contents_raw (result), obstack_base (&output),
Tom> + obstack_object_size (&output));
Yao> Compared with value_cstring, the difference is that expect_type is used
Yao> here, while type used in value_cstring is got from lookup_array_range_type.
Yao> struct type *stringtype
Yao> = lookup_array_range_type (char_type, lowbound, highbound + lowbound
Yao> - 1);
Yao> Any difference on these two type variables (expect_type vs. stringtype)?
Yes. You can wind up with a different "char" type following the logic
in c-lang.c. In this case some higher level will try to cast the string
to the correct type, which will try to force it to memory, leading to
the bad result.
The checks in the patch are intended to ensure that the expected type
isn't "too weird" -- that we don't do something nonsensical.
Tom
next prev parent reply other threads:[~2011-05-09 14:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-06 17:12 Tom Tromey
2011-05-09 3:11 ` Yao Qi
2011-05-09 14:54 ` Tom Tromey [this message]
2011-05-10 2:03 ` Yao Qi
2011-05-10 14:16 ` Tom Tromey
2011-05-11 8:06 ` Jan Kratochvil
2011-05-11 14:38 ` Jan Kratochvil
2011-05-11 19:42 ` Tom Tromey
2011-05-22 18:24 ` Jan Kratochvil
2011-05-23 20:24 ` Tom Tromey
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=m3wri0sz65.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.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