[Lldb-commits] [PATCH] fix lldb-mi hang on OSX

Илья К ki.stfu at gmail.com
Tue Dec 2 01:23:36 PST 2014


Hello Abid,

>RE: But I am still wondering why you need extra "return" in case of
-exec-run. It seems to work ok on Linux. Where is it blocking in OSX?
I had the same bug on OSX but "select" patch helped me (btw, thank Dawn for
that).
As I understood the problem occurs when trying to get filno(stdin), when
another thread sleeping in fgets(stdin). The filno() starts sleeping too
because stdin's mutex already locked by fgets(). Perhaps it related to
OSX's libc implementation and therefore it don't reproduced on Linux.

I wrote test, which doesn't works properly without WITH_SELECT_FIX:
<code>
#include <cstdio>
#include <thread>
#include <unistd.h>
#include <sys/select.h>

//#define WITH_SELECT_FIX

void first_func()
{
    char buf[1024];
#ifdef WITH_SELECT_FIX
    fd_set inset;
    FD_ZERO(&inset);
    FD_SET(0, &inset);
    select(1, &inset, NULL, NULL, NULL);
#endif
    char *line = fgets(buf, sizeof buf, stdin);
    printf("you entered: %s\n", buf);
}

void second_func()
{
    usleep(100);
    printf("fileno: ");
    printf("%d\n", fileno(stdin));
}

int main()
{
    std::thread first(first_func);
    std::thread second(second_func);
    printf("start test\n");
    first.join();
    second.join();
    printf("exiting\n");
    return 0;
}
</code>

>RE: Btw, if the problem is only with gdb-exit then an extra check for it
where we check for "quit" will work too.
As I said above, it doesn't solve a problem, it only fixes a certain case.

So I think you should accept the Dawn's "select" patch.

Thanks,
Ilia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20141202/19080692/attachment.html>


More information about the lldb-commits mailing list