Hi

I have checked a TCP-server which i wrote with valgrind-3.4.0,
and encountered these errors:
==15611== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 17 from 1)
==15611==
==15611== 1 errors in context 1 of 2:
==15611== Syscall param socketcall.accept(addr) points to unaddressable byte(s)
==15611==    at 0xA4BA01: accept (in /lib/libc-2.7.so)
==15611==    by 0x98D38F: (below main) (in /lib/libc-2.7.so)
==15611==  Address 0xbea43000 is not stack'd, malloc'd or (recently) free'd
==15611==
==15611== 1 errors in context 2 of 2:
==15611== Syscall param socketcall.accept(addrlen_in) points to
uninitialised byte(s)
==15611==    at 0xA4BA01: accept (in /lib/libc-2.7.so)
==15611==    by 0x98D38F: (below main) (in /lib/libc-2.7.so)
==15611==  Address 0xbea4233c is on thread 1's stack


I simplified the server to the point where it only calls accept (see below),
and the errors still prevail.
I compile it with
   g++ -g -Wall dummysrv.cpp -o dummysrv
(g++ (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33))

What do these messages mean and how can i fix that?
The position "below main" is a little bit vague...

Thank You
  Jody

Here's the code:


#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>

#include <unistd.h>
#include <stdio.h>
#include <string.h>



int main(int iArgC, char *apArgV[]) {

    int iPort = 27667;
    int iSock = socket(PF_INET, SOCK_STREAM, 0);
    if (iSock >= 0) {

        char sName[256];
        gethostname(sName, 256);
        struct hostent *phe = gethostbyname(sName);

        struct sockaddr_in sa;
        bzero((char *)&sa, sizeof(sa));
        sa.sin_family      = AF_INET;
        sa.sin_port        = htons(iPort);    // port is short
        sa.sin_addr.s_addr = htonl(INADDR_ANY);

        printf("hostent addr %0x\n", (*(struct in_addr*) phe->h_addr).s_addr);

        int iResult = bind(iSock, (struct sockaddr *)&sa,  sizeof(sa));

        struct sockaddr_in addrCli;
        bzero(&addrCli, sizeof(struct sockaddr_in));
        socklen_t       slAddr;

        if (iResult == 0) {
            int iSockCli = accept(iSock,(struct sockaddr *) &addrCli, &slAddr);
            if (iResult == 0) {
                printf("accept ok\n");
            } else {
                printf("accept failed");
            }
        } else {
            printf("bind error");
        }
        close(iSock);
    }
}

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to