[lldb-dev] Incorrect Linux/POSIX behaviour after main thread exits

Ed Maste emaste at freebsd.org
Fri Jul 5 10:09:08 PDT 2013

While looking into supporting threaded debugging on FreeBSD I
discovered an issue in the Linux implementation.

ProcessPOSIX::SendMessage now looks up a POSIXThread in m_thread_list
by tid, but is called from ::MonitorCallback with the pid of the
process.  As it happens this usually works on Linux, because the first
(or only) thread's tid is equal to the pid, resulting in a successful
FindThreadByID.  However, this fails if the main thread exits.

I set up a Debian VM to explore this, and the test case below causes
lldb to hang.

#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

void *
thread(void *arg)

main(int argc, char *argv[])
        pthread_t td;
        pthread_create(&td, NULL, thread, NULL);

        return 0;

More information about the lldb-dev mailing list