[Bug 33992] New: Deadlock in "thread step-over" after other thread exits

Bug ID 33992
Summary Deadlock in “thread step-over” after other thread exits
Product lldb
Version unspecified
Hardware PC
OS All
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter tberghammer@google.com
CC llvm-bugs@lists.llvm.org

Compile the following program with "clang++ -std=c++11 t.cpp -g -pthread":
#include <iostream>
#include <thread>

void foo() {
  std::cout << 1 << std::endl;
  std::cout << 2 << std::endl;
}

int main() {
  std::thread t1(foo);
  std::thread t2(foo);

  t2.join();
  t1.join();
}

* Set a breakpoint at foo ("breakpoint set -n foo")
* Start running the application and expect both thread to hit the breakpoint
during the same stop. If it isn't happen (possible) then start the application
again or continue the other threads until we have 2 threads stopped at the
breakpoint.
* Continue 1 of the threads using "thread continue 2" (2 is the thread index)
* The continued thread will exit, but LLDB won't get any new stop reason so it
won't go back to a state where the application considered to be stopped
(working as intended)
* Hit "Ctrl-C" to stop the application. At this point thread 3 expected to be
still at the breakpoint.
* Select thread 3 using "thread select 3"
* Try to execute "thread step-over" what will deadlock/livelock somewhere
inside LLDB and won't return. If we interrupt the thread again with "Ctrl-C" it
seems to be stuck at the same breakpoint even though we asked it to continue.