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: Adrian Sendroiu <adrian dot sendroiu at freescale dot com>
- To: Pedro Alves <palves at redhat 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 08:37:55 +0000
- 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>
> -----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?
Adrian