Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try to use a tool that traces system calls, e.g <code>strace</code> on Linux or <code>tusc</code> on HP-UX. When a deadlock occured, you should see the process hang in the blocking call. That's not a positive proof, though. It might be a regular block. You then need to determine whether the block may be resolved some time or not. This requires knowledge of the resource the process is waiting for.</p> <h3>Example</h3> <p>On RHEL4 there exists a... peculiarity... that may cause <code>ctime</code> to deadlock. Find an example program exhibiting this behaviour below:</p> <pre><code>#include &lt;sys/time.h&gt; #include &lt;time.h&gt; #include &lt;signal.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;unistd.h&gt; #include &lt;string.h&gt; volatile char *r; void handler(int sig) { time_t t; time(&amp;t); r = ctime(&amp;t); } int main() { struct itimerval it; struct sigaction sa; time_t t; int counter = 0; memset(&amp;sa, 0, sizeof(sa)); sa.sa_handler = handler; sigaction(SIGALRM, &amp;sa, NULL); it.it_value.tv_sec = 0; it.it_value.tv_usec = 1000; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 1000; setitimer(ITIMER_REAL, &amp;it, NULL); while(1) { counter++; time(&amp;t); r = ctime(&amp;t); printf("Loop %d\n",counter); } return 0; } </code></pre> <p>This will typically enter a deadlock after a couple thousand iterations. Now, attach <code>strace</code> like so</p> <pre><code>strace -s4096 -p&lt;PID&gt; </code></pre> <p>where <code>PID</code> is the program's process id. You'll see the program hang in a call with <code>FUTEX_WAIT</code> in the parameters. (I cannot quote the whole line as I currently don't have access to a RHEL4 machine, please excuse that).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload