Alessandro Ghedini <gh...@debian.org> writes:
> On mer, dic 25, 2013 at 02:52:32 -0800, Russ Allbery wrote:

>> Package: valgrind
>> Version: 1:3.9.0-4
>> Severity: minor

>> When valgrind is run with --trace-fds=yes, it reports AF_INET6
>> sockets open at exit as "pf-10" sockets instead of AF_INET6
>> sockets

> Guess you meant --track-fds=yes?

Whoops, yes, sorry.

>> Probably a missing case in its analysis of file descriptors.  It would
>> be nice for it to produce the same sort of output that it produces for
>> AF_INET sockets, or at least indicate that the socket is AF_INET6.

> Yeah, makes sense. There seems to be a working patch at [0], which looks
> good enough to me. Can you provide a small test case?

Sure thing.  This opens a pair of sockets for localhost port 11119 and
then connects one to the other so that you can also see the reporting
behavior of the connected address.

windlord:~> cat valgrind-test.c 
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>

/* Test case for valgrind reporting of unclosed AF_INET6 sockets. */
int
main(void)
{
    int server, client;
    struct sockaddr_in6 sin;
    struct in6_addr addr;
    int flag = 1;

    server = socket(PF_INET6, SOCK_STREAM, IPPROTO_IP);
    assert(server >= 0);
    setsockopt(server, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
    client = socket(PF_INET6, SOCK_STREAM, IPPROTO_IP);
    assert(client >= 0);
    memset(&sin, 0, sizeof(sin));
    sin.sin6_family = AF_INET6;
    sin.sin6_port = htons(11119);
    assert(inet_pton(AF_INET6, "::", &addr) == 1);
    sin.sin6_addr = addr;
    assert(bind(server, (struct sockaddr *) &sin, sizeof(sin)) == 0);
    assert(listen(server, 1) == 0);
    assert(connect(client, (struct sockaddr *) &sin, sizeof(sin)) == 0);
    return 0;
}
windlord:~> gcc -o valgrind-test valgrind-test.c
windlord:~> valgrind --track-fds=yes ./valgrind-test
==21125== Memcheck, a memory error detector
==21125== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==21125== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==21125== Command: ./valgrind-test
==21125== 
==21125== 
==21125== FILE DESCRIPTORS: 5 open at exit.
==21125== Open pf-10 socket 4:
==21125==    at 0x41395B7: socket (socket.S:63)
==21125==    by 0x40618C4: (below main) (libc-start.c:276)
==21125== 
==21125== Open pf-10 socket 3:
==21125==    at 0x41395B7: socket (socket.S:63)
==21125==    by 0x40618C4: (below main) (libc-start.c:276)
==21125== 
==21125== Open file descriptor 2: /dev/pts/25
==21125==    <inherited from parent>
==21125== 
==21125== Open file descriptor 1: /dev/pts/25
==21125==    <inherited from parent>
==21125== 
==21125== Open file descriptor 0: /dev/pts/25
==21125==    <inherited from parent>
==21125== 
==21125== 
==21125== HEAP SUMMARY:
==21125==     in use at exit: 0 bytes in 0 blocks
==21125==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==21125== 
==21125== All heap blocks were freed -- no leaks are possible
==21125== 
==21125== For counts of detected and suppressed errors, rerun with: -v
==21125== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

-- 
Russ Allbery (r...@debian.org)               <http://www.eyrie.org/~eagle/>


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to