[lldb-dev] Lldb-server spins forever in ptrace with 100% CPU on Linux Ubuntu 16.04

Eugene Birukov via lldb-dev lldb-dev at lists.llvm.org
Tue Dec 6 15:41:31 PST 2016


Hi,


I am running Linux Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-51-generic x86_64) in virtual machine.


When I am trying to write memory in my process, sometimes it works but sometimes lldb-server goes unresponsive. It spins with 100% CPU utilization and does not respond to any signals except SIGKILL.


I tried to debug it, but under debugger everything works perfectly :). Here are a couple observations:


1. I believe that lldb-server spins inside ptrace. I put breakpoint on the highlighted line, and it does not hit. If I put breakpoint on line before, it hits but lldb-server hangs.


Error

NativeProcessLinux::PtraceWrapper(int req, lldb::pid_t pid, void *addr, void *data, size_t data_size, long *result)

{

    Error error;

    long int ret;


    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PTRACE));


    PtraceDisplayBytes(req, data, data_size);


    errno = 0;

    if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET)

        ret = ptrace(static_cast<__ptrace_request>(req), static_cast< ::pid_t>(pid), *(unsigned int *)addr, data);

    else

        ret = ptrace(static_cast<__ptrace_request>(req), static_cast< ::pid_t>(pid), addr, data);


    if (ret == -1)

        error.SetErrorToErrno();

2. It seems that hang is caused by the client trying to read response too fast. I mean, if I step through the client code it works - i.e. there is significant delay between client writing into pipe and issuing ::select to wait for response.


Any advice how to deal with the situation except putting random sleeps in random places?


Thanks,

Eugene


Sent from Outlook<http://aka.ms/weboutlook>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20161206/6f332a57/attachment.html>


More information about the lldb-dev mailing list