Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

timer_create gives memory leaks issue "Syscall param timer_create(evp) points to uninitialised byte(s)"

Tags:

c++

    struct sigevent timerEvent;
    memset(&timerEvent, 0, sizeof(timerEvent));

    timerEvent.sigev_value.sival_int = 0;
    timerEvent.sigev_value.sival_ptr = diaBase;
    timerEvent.sigev_notify = SIGEV_THREAD;
    timerEvent._sigev_un._sigev_thread._function = function;
    timerEvent._sigev_un._sigev_thread._attribute = NULL;

    timer_t timer_ID;

    int retVal;
    if((retVal = timer_create (CLOCK_REALTIME, &timerEvent, &timer_ID )) != -1)
    {
            printf("Timer Created Successfully: %ld\n", timer_ID );
    }
    else
    {
            printf("Error Creating Timer\n");
    }

Memory Leak, the following denotes

Syscall param timer_create(evp) points to uninitialised byte(s)
==27384==    at 0x530595: timer_create (in /lib/librt-2.5.so)
like image 695
Renuka Avatar asked May 25 '11 09:05

Renuka


2 Answers

This seems to be a known valgrind issue:

http://bugs.kde.org/show_bug.cgi?id=124478

...and...

http://www.google.co.uk/search?source=ig&hl=en&rlz=&q=Syscall+param+timer_create%28evp%29+points+to+uninitialised+byte%28s%29&btnG=Google+Search

like image 142
Roddy Avatar answered Nov 11 '22 13:11

Roddy


Had the same problem and made valgrind happy with this:

timer_t timerId;

struct sigevent* sigev = static_cast<struct sigevent*>(calloc(1, sizeof(struct sigevent)));
sigev->sigev_notify = SIGEV_SIGNAL;
sigev->sigev_signo = SIGALRM;
sigev->sigev_value.sival_ptr = &timerId;

timer_create(CLOCK_REALTIME, sigev, &timerId);

// Use the timer
...

// After totally done with the timer
free(sigev);

I used this as a reference: http://pubs.opengroup.org/onlinepubs/7908799/xsh/timer_create.html

like image 1
user79878 Avatar answered Nov 11 '22 13:11

user79878