Programming

Strace – hanging at futex, FUTEX_WAIT

Whenever i am done with all the debugging tools and techniques to debug never ending processes, and still with no solution at hand, strace always comes to escape. I simply love this utility. 🙂

Strace is the tool that traces the execution of system calls. Strace allows you to analyse what your processes are doing at any time with no need of re-compiling, re-running/running in front the processes.The syntax to use strace is:

strace -p <pid>

If the process to be monitored is multithreaded, you need to run strace with multiple pid’s as argument else you will get following output (if you try to run it with just parent id as argument),

[root@upi1 bin]# strace -p 24866
Process 24866 attached – interrupt to quit
futex(0xa280a0c, FUTEX_WAIT, 1, NULL

which simply means you are tracing the original parent thread, and it’s doing nothing but waiting for some other threads to finish.

To get the pid’s of various threads executing in a single process, run the following command

ps -efL|grep <Process Name>

This will show you something like below:

[root@upi1 bin]# ps -efL|grep client
root 13725 4922 13725 0 1 13:55 pts/1 00:00:00 grep cfg
root 24813 1 24813 0 7 11:07 pts/1 00:00:00 ./client -i /home/corba/conf/har.cfg -r /home/corba/conf/resources.cfg
root 24813 1 24821 0 7 11:07 pts/1 00:00:02 ./client -i /home/corba/conf/har.cfg -r /home/corba/conf/resources.cfg
root 24813 1 24822 0 7 11:07 pts/1 00:00:02 ./client -i /home/corba/conf/har.cfg -r /home/corba/conf/resources.cfg
root 24813 1 24823 0 7 11:07 pts/1 00:00:01 ./client -i /home/corba/conf/har.cfg -r /home/corba/conf/resources.cfg

where 24813 is PPID, parent process PID and 24821,24822,24823 are pid’s being assigned to threads spawned by parent process. To analyse, system calls being executed by any thread, just pass its pid to strace as given below:

strace -p 24821

3 down vote accepted

If there’s multiple threads within that process, you’ll need to give strace multiple -p options, specifying the ID of each one.

13 thoughts on “Strace – hanging at futex, FUTEX_WAIT

  1. I agree to Andrew’s point of view:

    strace -f -p is the weapon of choice to trace multithreaded processes.

    Instead of searching fo all the children with a lengthy ps command let -f do the work!

    Best regards.

  2. i use strace at android eclipse

    my problem is this error

    output

    “futex(0x13830c, FUTEX_WAIT, 0, NULL) = 0”

    I use strace for all threads pid but problem is not solved!

    why?

    Strace -e trace=open -p 125 -p 126 -p 127 -p 129

    and erorr dont solve and show again !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s