[Bug 51833] New: TestGuiBasicDebug.py is flaky - lack of process event synchronization ?

Bug ID 51833
Summary TestGuiBasicDebug.py is flaky - lack of process event synchronization ?
Product lldb
Version unspecified
Hardware All
OS All
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter labath@google.com
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

Once every while, the "finish" command in the test fails to step out of the
designated function. Or rather, it fails to stop after stepping out of the
function -- instead, it continues stepping until the application terminates.

My analysis of the test logs (see attachment) suggests that this if due to poor
event handling discipline. After requesting an (asynchronous) step out, the gui
command goes back to its normal business. The first order of business is
usually to redraw the screen (see Application::Run). If it does that too
quickly, it can happen that the command will start drawing the threads before
the "running" event propagates to public. This means that the all the
StateIsStoppedState guards that the command uses to prevent accessing a running
process will fail. This will cause lldb to start computing (a bogus) the stack
frame list in parallel to its internal processing of the step over operation.
When the inferior stops, the step over thread plan will be presented with the
inconsistent stack frame, which will cause it to think that it has _not_
stepped out of the function, and will trigger another resume. That will
terminate the inferior.

It's not fully clear to me how to fix this. Presumably, the gui should process
the running event resulting from the resume command before doing anything else.
It has some code which tries to do that, but since it only does a poll, it will
not capture the event if it has not been already sent.

It also seems that the process run lock should have prevented anyone from
tampering with the process while it was running.