Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the error VgTs_WaitSys mean in Valgrind?

I have a server written in C that spawns a new thread whenever a new client connects. In order to test my server I have written a script that emulates 500 clients. The server handles the first couple of hundred clients and towards the end I get the following error from Valgrind:

Thread 456: status = VgTs_WaitSys
==4182==    at 0x4E383EC: recv (recv.c:34)
==4182==    by 0x4017F1: process_data (socket2.h:45)
==4182==    by 0x40195E: thread (FBServer.c:82)
==4182==    by 0x4E30A03: start_thread (pthread_create.c:300)
==4182==    by 0x532DD4C: clone (clone.S:112)

Thread 457: status = VgTs_WaitSys
==4182==    at 0x4E383EC: recv (recv.c:34)
==4182==    by 0x4017F1: process_data (socket2.h:45)
==4182==    by 0x40195E: thread (FBServer.c:82)
==4182==    by 0x4E30A03: start_thread (pthread_create.c:300)
==4182==    by 0x532DD4C: clone (clone.S:112)

...

Thread 499: status = VgTs_WaitSys
==4182==    at 0x4E383EC: recv (recv.c:34)
==4182==    by 0x4017F1: process_data (socket2.h:45)
==4182==    by 0x40195E: thread (FBServer.c:82)
==4182==    by 0x4E30A03: start_thread (pthread_create.c:300)
==4182==    by 0x532DD4C: clone (clone.S:112)

At line 82 in FBServer.c, the thread calls a function called process_data that receives data from the client. The function process_data is shown below:

void process_data(int clientSock)
{
    size_t n;
    char jstring[MAX_LEN + 1];
    int bytes_received_so_far = 0;
    int bytes_count;
    char *buf = NULL;

    while(bytes_count = recv(clientSock, jstring, MAX_LEN, 0))
    {
        if(bytes_count <= 0)
        {
            close(clientSock);
            pthread_exit(NULL);
        }

        printf("Bytes received = %d\n", bytes_count);                           
        jstring[bytes_count] = '\0';

        ...
        ...
    }
}

Can someone help me in interpreting the error messages.

like image 307
Programmer Avatar asked Nov 13 '22 19:11

Programmer


1 Answers

What version of Valgrind are you using?

About the only comment I could find in the source was:

VgTs_WaitSys, /* waiting for a syscall to complete */

So it appears to indicate that the program is just blocking on a system call (recv in your case). I'm not sure, but this may not be an error at all, just some extra info kicked out by Valgrind.

like image 110
zdav Avatar answered Dec 07 '22 22:12

zdav