From: Andrew Burgess <aburgess@redhat.com>
To: Luis Machado <luis.machado@arm.com>, Tom Tromey <tom@tromey.com>,
Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Fix crash with "maintenance print arc"
Date: Fri, 29 Apr 2022 11:18:12 +0100 [thread overview]
Message-ID: <87mtg4nqfv.fsf@redhat.com> (raw)
In-Reply-To: <6d4bd7ec-89de-c115-3205-b0d1999b3aab@arm.com>
Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:
> On 4/28/22 16:26, Tom Tromey wrote:
>>>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:
>>
>> Luis> While doing something else, I noticed GDB crashed with
>> Luis> "maintenance print arc".
>>
>> I think the bug here is that this uses add_show_prefix_cmd and not
>> add_basic_prefix_cmd. See the appended, which also fixes the crash.
>
> Ah, you're right. It did look odd why we were feeding maint commands to
> code that is supposed to handle show commands.
>
>>
>> Luis> This happens because the code expects to find a "show" string pattern
>> Luis> within "maintenance print arc", since "arc" here is a prefix, and skip it.
>> Luis> In this case though, it won't find it, and we will have a bad pointer
>> Luis> getting dereferenced.
>>
>> This looks reasonable to me.
>
> Should we prevent further situations like this by asserting that we
> don't have a class_maintenance prefix being registered as a show
> prefix?
Would this not trigger for all the existing 'maint show ...' commands?
Thanks,
Andrew
>
>>
>> Tom
>>
>> diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
>> index 98bd1c4bc0a..3edfd466f3b 100644
>> --- a/gdb/arc-tdep.c
>> +++ b/gdb/arc-tdep.c
>> @@ -2474,11 +2474,11 @@ _initialize_arc_tdep ()
>> /* Register ARC-specific commands with gdb. */
>>
>> /* Add root prefix command for "maintenance print arc" commands. */
>> - add_show_prefix_cmd ("arc", class_maintenance,
>> - _("ARC-specific maintenance commands for printing GDB "
>> - "internal state."),
>> - &maintenance_print_arc_list,
>> - 0, &maintenanceprintlist);
>> + add_basic_prefix_cmd ("arc", class_maintenance,
>> + _("ARC-specific maintenance commands for printing GDB "
>> + "internal state."),
>> + &maintenance_print_arc_list,
>> + 0, &maintenanceprintlist);
>>
>> add_cmd ("arc-instruction", class_maintenance,
>> dump_arc_instruction_command,
next prev parent reply other threads:[~2022-04-29 10:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 10:07 Luis Machado
2022-04-27 10:43 ` Andrew Burgess
2022-04-27 11:00 ` Luis Machado
2022-04-28 15:27 ` Tom Tromey
2022-04-29 10:20 ` Andrew Burgess
2022-04-28 15:26 ` Tom Tromey
2022-04-29 8:58 ` Luis Machado
2022-04-29 10:18 ` Andrew Burgess [this message]
2022-04-29 10:39 ` Luis Machado
2022-04-29 11:25 ` Pedro Alves
2022-05-05 9:31 ` Luis Machado
2022-05-27 13:34 ` 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=87mtg4nqfv.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@arm.com \
--cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).