Kudos and question on the decoding of socket descriptors 'paths' in some network calls

Philippe Ombredanne pombredanne at nexb.com
Thu Jan 30 17:11:25 UTC 2014

Howdy fierce tracers and many thanks for this great tool!
I noticed something which is odd: descriptors for sockets are not
consistently decoded.
I am using a stock strace 4.8 on a 64 bits machine:
If I trace a simple wget like this (with -y):
strace -qq -ff -y -a1 -o wg wget http://nexb.com
I get some thing like this (shortened for brevity):

connect(3, {sa_family=AF_INET, sin_port=htons(53),
sin_addr=inet_addr("")}, 16) = 0
poll([{fd=3<socket:[69384967]>, events=POLLOUT}], 1, 0) = 1 ([{fd=3,
sendto(3, "\4G\1\0\0\1\0\0"..., 26, MSG_NOSIGNAL, NULL, 0) = 26
poll([{fd=3<socket:[69384967]>, events=POLLIN}], 1, 5000) = 1 ([{fd=3,
ioctl(3<socket:[69384967]>, FIONREAD, [87]) = 0
recvfrom(3, "\4G\201\200\0\1\0\0"..., 1024, 0, {sa_family=AF_INET,
sin_port=htons(53), sin_addr=inet_addr("")}, [16]) = 87
close(3<socket:[69384967]>) = 0

The issue is that the socket descriptor 3 is not always decoded on all
calls, in particular the connect, sendto and recvfrom calls.
I would have expected something like this instead when using a -y:
connect(3<socket:[69384967]>, {sa_family=AF_INET, sin_port=htons(53),
sin_addr=inet_addr("")}, 16) = 0
sendto(3<socket:[69384967]>, "\4G\1\0\0\1\0\0"..., 26, MSG_NOSIGNAL,
NULL, 0) = 26
recvfrom(3<socket:[69384967]>, "\4G\201\200\0\1\0\0"..., 1024, 0,
{sa_family=AF_INET, sin_port=htons(53),
sin_addr=inet_addr("")}, [16]) = 87

Is this a bug?
Note that close (which is both a network and file call) shows the
decoded socket alright.
Let me work out a patch
Philippe Ombredanne

More information about the Strace-devel mailing list