[Lldb-commits] [PATCH] fix lldb-mi hang on OSX
zturner at google.com
Tue Dec 2 09:32:02 PST 2014
I don't work on OSX (or use lldb-mi), so it was mostly just a passing
comment. If there are no other objections I won't block it either.
On Tue, Dec 2, 2014 at 9:27 AM Ilia K <ki.stfu at gmail.com> wrote:
> Hi Zachary,
> We can save file descriptor once and don't use fileno() every time we need
> it but it may doesn't work and it doesn't resolve design flaw. Redesign the
> lldb-mi is a big task which can take a long time.
> Currently problem is that OSX's implementation of libc hangs on it in
> mutex_lock() and this patch, as I understood, avoids this behaviour.
> I think the 'select' patch should be committed as is.
> On Tue, Dec 2, 2014 at 7:33 PM, Zachary Turner <zturner at google.com> wrote:
>> I kind of feel like calling fgets from one thread and fileno from another
>> thread indicates a design flaw. Is there any way to fix the design problem
>> instead of this particular bug?
>> On Tue, Dec 2, 2014 at 1:24 AM Илья К <ki.stfu at gmail.com> wrote:
>>> 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:
>>> #include <cstdio>
>>> #include <thread>
>>> #include <unistd.h>
>>> #include <sys/select.h>
>>> //#define WITH_SELECT_FIX
>>> void first_func()
>>> char buf;
>>> #ifdef WITH_SELECT_FIX
>>> fd_set inset;
>>> FD_SET(0, &inset);
>>> select(1, &inset, NULL, NULL, NULL);
>>> char *line = fgets(buf, sizeof buf, stdin);
>>> printf("you entered: %s\n", buf);
>>> void second_func()
>>> printf("fileno: ");
>>> printf("%d\n", fileno(stdin));
>>> int main()
>>> std::thread first(first_func);
>>> std::thread second(second_func);
>>> printf("start test\n");
>>> return 0;
>>> >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
>>> So I think you should accept the Dawn's "select" patch.
>>> lldb-commits mailing list
>>> lldb-commits at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lldb-commits