[lldb-dev] [Bug 21553] New: Simple c++ program using lldb hangs in std::condition_variable desctructor when linked with -lpthreads on linux with gcc

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 12 18:47:00 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=21553

            Bug ID: 21553
           Summary: Simple c++ program using lldb hangs in
                    std::condition_variable desctructor when linked with
                    -lpthreads on linux with gcc
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at cs.uiuc.edu
          Reporter: sbest at blueshiftinc.com
    Classification: Unclassified

Consider the following simple stand-alone c++ that does nothing other than
initialize lldb, then use a std::condition_variable.

#include <iostream>
#include <condition_variable>
#include <mutex>

#include "lldb/API/LLDB.h"

int main(int argc, char** argv) 
{
    lldb::SBDebugger::Initialize();

    {
        std::condition_variable g_condition;
        {
            std::mutex g_mutex;
            std::unique_lock<std::mutex> lock(g_mutex);
            g_condition.wait_for(lock, std::chrono::seconds(1));

            std::cout << "going out of scope 1\n";        
        }
        std::cout << "going out of scope 2\n";        
    }
    std::cout << "done\n";
}

When the program is built on Unbuntu 14.04, x86_64 with the following command
line:

g++  hang.cpp -g -O0 -m64 -std=c++11 -Ipath_to_lldb/include
-Lpath_to_lldb_build/lib -llldb -lpthread -o "hang"

Remember to also set environment variable: 
export LD_LIBRARY_PATH=path_to_lldb_build/lib

Program hangs after printing "going out of scope 2", and never prints "done". 
If I interrupt the hang, it is waiting on a mutex inside the
std::condition_variable destructor.

Remove "-lpthread" from link flags and program works no problem. 
std::condition_variable is included by "-std=c++11", but this behavior is
platform dependent.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20141113/4a753cc1/attachment.html>


More information about the lldb-dev mailing list