Purify error in Signal handler

A

Achint Mehta

Hi,

I am running purify on my program (on linux with gcc ver. 3.4.6)
I have installed a signal handler (for timer) using sigaction.
I am passing a pointer (data) into the sival_ptr which I intend to
access later in the signal handler.

timer_event.sigev_notify = SIGEV_SIGNAL;
timer_event.sigev_signo = SIGRTMIN;
timer_event.sigev_value.sival_ptr = data;

sigfillset (&timer_action.sa_mask);
timer_action.sa_flags = SA_SIGINFO ; /* realtime signal */
timer_action.sa_sigaction = handle_download_retry;
sigaction (SIGRTMIN, &timer_action, NULL);
....
timer_create(...)
...
timer_settime(...)


When I access this pointer in the signal handler purify gives me
Memory Segment error (which means that I am accessing memory from some
other segment)

I was accessing the pointer as
void handle_download_retry (int sigval, siginfo_t *extra, void *what)
{
. . .
p_msgData->data = (void *)(extra->si_value.sival_ptr); /* MSE :
Memory segment error */

}

However, even if I change the
p_msgData->data = (void *)(extra->si_value.sival_ptr);
to
p_msgData->data = (void *)(extra);
even then I get the error which means that purify doesn't like "extra"
being accessed.

Although the program does not dump core (with or without purify) but
can somebody tell me whether the signal handler code is correct ?

Thanks in advance.

Regards,
Achint
 
B

Beej Jorgensen

However, even if I change the
p_msgData->data = (void *)(extra->si_value.sival_ptr);
to
p_msgData->data = (void *)(extra);
even then I get the error which means that purify doesn't like "extra"
being accessed.

Or maybe p_msgData is not valid, and the problem is when you try to
access p_msgData->data?

Try comp.unix.programmer for help with the real-time signals stuff.

-Beej
 
A

Achint Mehta

Or maybe p_msgData is not valid, and the problem is when you try to
access p_msgData->data?

Try comp.unix.programmer for help with the real-time signals stuff.

-Beej


Thanks for the suggestion Beej.
I tried some combinations such as
p_msgData->data = 10;
and I did not get the purify error. So it seems that the error is
because of accessing "extra".
Also, p_msgData is a pointer to a global variable. Hope this is ok.

I will repost my query to comp.unix.programmer.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top