c4-project / c4t

Runs concurrent C compiler tests
MIT License
1 stars 0 forks source link

Data race in lifter #88

Closed MattWindsor91 closed 3 years ago

MattWindsor91 commented 3 years ago

In the lifter, we have the following code:

mrng := p.Metadata.Rand()
return builder.ParBuild(ctx, 20, p.Corpus, cfg, func(ctx context.Context, s subject.Named, rq chan<- builder.Request) error {
    j := l.makeJob(p, s, mrng, rq)
    return j.Lift(ctx)
})

This introduces a data race on mrng, which is not thread-safe. On close analysis, this RNG seems to be a copy-paste error from the fuzzer (maybe we should check to make sure the fuzzer also doesn't have this problem), and might be removable. If not, then the RNG is just used to seed a new RNG later on, so we could pre-generate the seeds for each subject in a map[string]int64 or something before parallelisation.