This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 2/2] mi-out: Implement mi redirection using a stack.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]