In msm__handle_write under if (is_SHVAL_ShR(wold)) { we don't check
happens_before...
We can't, because when we are in ShR we don't have SegmentIDs...
On Dec 13, 2007 3:12 PM, Konstantin Serebryany <
[EMAIL PROTECTED]> wrote:
> I tried this patch with a test where multiple workers are present -- it
> does not help. :(
> Or is this another problem?
> another test attached.
>
> --kcc
>
> --kcc
> #include <pthread.h>
> #include < stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <assert.h>
> // This test is race-free,
> // but helgrind 3.3.0 reports a race iff n_workers >= 2.
> //
> // main worker1,worker2,...,workerN
> //
> // 1. start(all workers)
> // a. read(GLOB)
> // /----------b. signal(CV)
> // 2. wait(CV) <-----/
> // 3. write(GLOB)
> static int COND = 0;
> static int GLOB = 0;
> static pthread_cond_t CV = PTHREAD_COND_INITIALIZER;
> static pthread_mutex_t MU = PTHREAD_MUTEX_INITIALIZER;
>
> void *run_pm(void*) {
> sleep(2); // we want waiter to get there first
> int val = GLOB;
> pthread_mutex_lock(&MU);
> COND++;
> fprintf(stderr, "Signaling: COND: %d; val=%d\n", COND, val);
> pthread_cond_signal(&CV);
> pthread_mutex_unlock(&MU);
> return NULL;
> }
>
> int main(int argc, char **argv) {
> pthread_t threads[100];
> int n_workers = argc == 2 ? atoi(argv[1]) : 2;
>
> for (int i = 0; i < n_workers; i++) {
> pthread_create(&threads[i], NULL, run_pm, NULL);
> }
>
> bool entered_cond_wait = false;
>
> pthread_mutex_lock(&MU);
> while (COND != n_workers) {
> entered_cond_wait = true;
> printf("Blocking: COND=%d\n", COND);
> pthread_cond_wait(&CV, &MU);
> printf("Waking: COND=%d\n", COND);
> }
> pthread_mutex_unlock(&MU);
>
> assert(COND == n_workers); // being paranoid
> assert(entered_cond_wait); // because otherwise is unfair
>
> GLOB = 2; // race is reported here
>
> fprintf(stderr, "GLOB: %d\n", GLOB);
> for (int i = 0; i < n_workers; i++) {
> pthread_join(threads[i], NULL);
> }
> return 0;
>
> }
>
>
>
> On Dec 13, 2007 12:24 PM, Julian Seward <[EMAIL PROTECTED]> wrote:
>
> > On Thursday 13 December 2007 09:07, Konstantin Serebryany wrote:
> > > But isn't it expensive?
> > >
> > > On Dec 13, 2007 11:01 AM, Julian Seward < [EMAIL PROTECTED]> wrote:
> > > > On Thursday 13 December 2007 08:44, Konstantin Serebryany wrote:
> > > > > Hi,
> > > > >
> > > > > The same false positive appears when mixing mutexes and
> > semaphores.
> > > > > Test attached.
> > > > > As with cond vars, we are able to transition Excl(T1)->Excl(T2),
> > but
> > > > > can not do ShM(T1,T2)->Excl(T2).
> > > > >
> > > > > As I understand, fixing this properly will require storing
> > SegmentID in
> > > >
> > > > all
> > > >
> > > > > shadow words, not only in those that are in Exclusive state.
> > > > > This will hardly squeeze into 32 bits though, need 64... :(
> > > >
> > > > No, I don't think so. We just need to do the same memory ownership
> > > > transition for semaphores that the "cvhack" patch does for CVs.
> > I'll
> > > > extend the current patch.
> >
> > Here is version 2 of the cvhack patch. This makes your semaphore test
> > run clean (with --happens-before=cvhack).
> >
> > J
> >
> >
> >
>
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers