>> Helgrind cannot know that the child thread (run_pm) does not access COND
again after the pthread_cond_signal
I thought the logic related to cond_wait() is supposed to catch this.
COND is accessed before cond_signal() in child thread and after cond_wait()
in parent thread.
If COND is accessed outside of critical sections in both threads (but still,
before cond_signal in child and after cond_wait in parent), helgrind is
quiet.

>> If you change the order of these two lines, to
Sure. But thread_join is not what is usually done in presence of thread
pools...
Threads tend to live forever.
This program is just a short reproducer.

--kcc


On Dec 5, 2007 1:41 PM, Julian Seward <[EMAIL PROTECTED]> wrote:

>
> > I get a report about a race from helgrind, while everything looks well
> > synchronized to me.
> > Am I wrong?
>
> >   fprintf(stderr, "COND: %d\n", COND);
> >   pthread_join(threadid, NULL);
>
> The problem is here.  By the time you get here, Helgrind knows that
> COND has been accessed by both parent and child threads, and MU is
> used to protect it.  But now you are using it without a lock.
>
> Helgrind cannot know that the child thread (run_pm) does not access
> COND again after the pthread_cond_signal (how could it know this
> without doing static analysis of the child's code?)
>
> If you change the order of these two lines, to
>
> >   pthread_join(threadid, NULL);
> >   fprintf(stderr, "COND: %d\n", COND);
>
> then it stops complaining.  Because now the pthread_join tells Helgrind
> that the child can no longer access COND.  That means, after the
> pthread_join,
> the parent is the only thread able to access COND, so it is OK for it
> to access COND without a lock.
>
> J
>
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to