This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 2/2] mi-out: Implement mi redirection using a stack.
- From: Pedro Alves <palves at redhat dot com>
- To: Adrian Sendroiu <adrian dot sendroiu at freescale dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, "tromey at redhat dot com" <tromey at redhat dot com>
- Date: Wed, 30 Jul 2014 12:44:00 +0100
- Subject: Re: [PATCH v2 2/2] mi-out: Implement mi redirection using a stack.
- Authentication-results: sourceware.org; auth=none
- References: <87ha26liw6 dot fsf at fleche dot redhat dot com> <1406288037-11470-1-git-send-email-adrian dot sendroiu at freescale dot com> <53D7B5BE dot 6020702 at redhat dot com> <f97e74554a0b462ab9eba17c90559a1f at BLUPR03MB136 dot namprd03 dot prod dot outlook dot com>
On 07/30/2014 09:37 AM, Adrian Sendroiu wrote:
>> -----Original Message-----
>> From: Pedro Alves [mailto:palves@redhat.com]
>> Sent: Tuesday, July 29, 2014 5:55 PM
>> To: Sendroiu Adrian-B46904; gdb-patches@sourceware.org;
>> tromey@redhat.com
>> Subject: Re: [PATCH v2 2/2] mi-out: Implement mi redirection using a
>> stack.
>>
>> I'm guessing we can trigger this by using "save breakpoints" while
>> logging is enabled, like gdb.base/ui-redirect.exp ?
>> I think it'd be very good if a test to the testsuite was added.
>> Sounds like gdb.mi/mi-logging.exp would be a good place?
>>
>> --
>> Thanks,
>> Pedro Alves
>
> This won't trigger the bug, because the logging code doesn't call ui_out_redirect if the interpreter is MI. The way I caught it was through some python script that executes commands and catches their output into a string. For example, if you have
>
> gdb.execute("break main", False, True)
>
> The call sequence will be something like:
> execute_command_to_string
> ui_out_redirect
> execute_command
> ...
> mi_breakpoint_created
> ui_out_redirect
>
> Then, after executing this, the mi_uiout->data->buffer will incorrectly point to a freed ui_file structure, and any subsequent command will overwrite the pointers inside this ui_file with random data, causing a crash.
>
> Do you have any suggestions on how to make a test case from this scenario?
I'm not sure what specific suggestion you're looking after. :-)
Sound like you'd add a test that does that exactly ?
You'd either base on, or add to mi-logging.exp, and do something like:
mi_gdb_test "python gdb.execute("break main", False, True)" ...
mi_gdb_test <some MI command that causes a crash> ...
(and skip the test if skip_python_tests is true)
Thanks,
Pedro Alves