<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi,</p>
<p><br>
</p>
<p>I am running Linux <span>Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-51-generic x86_64) in virtual machine. </span></p>
<p><span><br>
</span></p>
<p><span>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.</span></p>
<p><span><br>
</span></p>
<p><span>I tried to debug it, but under debugger everything works perfectly :). Here are a couple observations:</span></p>
<p><span><br>
</span></p>
<p><span>1. I believe that lldb-server spins inside ptrace. I put <span style="background-color: rgb(255, 255, 0);">
breakpoint </span>on the <span style="background-color: rgb(255, 255, 255);">highlighted</span><span style="background-color: rgb(255, 255, 255);"> </span>line, and it does not hit. If I put
<span style="background-color: rgb(0, 255, 0);">breakpoint </span>on line before, it hits but lldb-server hangs.</span></p>
<p><br>
</p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">Error</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">NativeProcessLinux::PtraceWrapper(int req, lldb::pid_t pid, void *addr, void *data, size_t data_size, long *result)</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;">{</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> Error error;</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> long int ret;</span></div>
<p></p>
<p></p>
<div><br>
</div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PTRACE));</span></div>
<p></p>
<p></p>
<div><br>
</div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> PtraceDisplayBytes(req, data, data_size);</span></div>
<p></p>
<p></p>
<div><br>
</div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> <span style="background-color: rgb(0, 255, 0);">
errno = 0;</span></span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET)</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> ret = ptrace(static_cast<__ptrace_request>(req), static_cast< ::pid_t>(pid), *(unsigned int *)addr, data);</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> else</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> ret = ptrace(static_cast<__ptrace_request>(req), static_cast< ::pid_t>(pid), addr, data);</span></div>
<p></p>
<p></p>
<div><br>
</div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt; background-color: rgb(255, 255, 0);"> if (ret == -1)</span></div>
<p></p>
<p></p>
<div><span style="font-family: "Courier New", monospace; font-size: 8pt;"> error.SetErrorToErrno();</span></div>
<p></p>
</blockquote>
<p></p>
<div></div>
<div><br>
</div>
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.
<p></p>
<p><span></p>
<div><br>
</div>
</span>
<p></p>
<p><span>Any advice how to deal with the situation except putting random sleeps in random places?</span></p>
<p><span><br>
</span></p>
<p><span>Thanks,</span></p>
<p><span>Eugene</span></p>
<p><br>
</p>
<div id="Signature">
<p>Sent from <a href="http://aka.ms/weboutlook" id="LPNoLP">Outlook</a><br>
</p>
</div>
</div>
</body>
</html>