From: Weimin Pan <weimin.pan@oracle.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: [pushed][PATCH5 PR gdb/16959] gdb hangs in infinite recursion
Date: Mon, 02 Apr 2018 19:28:00 -0000 [thread overview]
Message-ID: <0a994561-f704-3582-fe01-c3a10c0f1fff@oracle.com> (raw)
In-Reply-To: <20cf4b23322670e4dc513183ef2dda45@polymtl.ca>
This patch has been pushed.
Thanks.
On 3/29/2018 10:08 PM, Simon Marchi wrote:
> On 2018-03-28 16:44, Weimin Pan wrote:
>> The original problem was fixed (see related PR 22242). But using a
>> typedef
>> as the declared type for a static member variable, as commented in
>> this PR,
>> is still causing gdb to get into infinite loop when printing the static
>> member's value. This problem can be reproduced as follows:
>>
>> % cat t.cc
>> class A {
>> Â Â Â typedef A type;
>> public:
>> Â Â Â bool operator==(const type& other) { return true; }
>>
>> Â Â Â static const type INSTANCE;
>> };
>>
>> const A A::INSTANCE;
>>
>> int main() {
>> Â Â Â A a;
>> Â Â Â if (a == A::INSTANCE) {
>> Â Â Â Â Â Â Â return -1;
>> Â Â Â }
>> Â Â Â return 0;
>> }
>> % g++ -g t.cc
>> % gdb -ex "start" -ex "p a" a.out
>>
>> The fix is rather trivial - in cp_print_static_field(), should call
>> check_typedef() to get the static member's real type and use it to
>> check whether it's a struct or an array.
>>
>> As Simon suggested, I've added a new test case to the testsuite
>> and am passing the original type, not the real type, as argument
>> to both cp_print_value_fields() and val_print().
>>
>> Re-tested on both aarch64-linux-gnu and amd64-linux-gnu. No regressions.
>
> Hi Weimin,
>
> Could you change the title to something more descriptive about what
> the change/fix is, rather than the problem being fixed? For example,
> "Fix infinite recursion when printing static member with typedef".
>
> It is ok to push with that fixed (feel free to ask if you still need
> some guidance).
>
> Thanks!
>
> Simon
prev parent reply other threads:[~2018-04-02 19:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-28 21:11 [PATCH5 " Weimin Pan
2018-03-30 5:09 ` Simon Marchi
2018-03-30 21:44 ` Weimin Pan
2018-03-30 22:05 ` Simon Marchi
2018-03-30 22:39 ` Weimin Pan
2018-03-30 22:52 ` Joel Brobecker
2018-03-30 23:32 ` Weimin Pan
2018-03-30 23:45 ` Joel Brobecker
2018-03-30 23:32 ` Weimin Pan
2018-03-30 23:41 ` Joel Brobecker
2018-03-31 0:31 ` Weimin Pan
2018-03-31 1:52 ` Joel Brobecker
2018-03-31 3:32 ` Wei-min Pan
2018-04-02 13:44 ` Joel Brobecker
2018-04-02 17:27 ` Wei-min Pan
2018-04-02 17:53 ` Joel Brobecker
2018-04-02 19:28 ` Weimin Pan [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=0a994561-f704-3582-fe01-c3a10c0f1fff@oracle.com \
--to=weimin.pan@oracle.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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