By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Purify error in Signal handler

P: n/a
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

Feb 23 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <11*********************@k78g2000cwa.googlegroups. com>,
Achint Mehta <ac*********@gmail.comwrote:
>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

Feb 23 '07 #2

P: n/a
On Feb 23, 3:18 pm, Beej Jorgensen <b...@beej.uswrote:
In article <1172228497.165452.91...@k78g2000cwa.googlegroups. com>,

Achint Mehta <achintme...@gmail.comwrote:
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 thatpurifydoesn'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

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.

Feb 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.