[m-rev.] for review: fix a bug with cloning thread local mutables
Julien Fischer
jfischer at opturion.com
Wed Oct 14 10:23:13 AEDT 2026
On Wed, 14 Oct 2026 at 10:17, Peter Wang <novalazy at gmail.com> wrote:
>
> On Tue, 13 Oct 2026 22:18:55 +1100 Julien Fischer <jfischer at opturion.com> wrote:
> > For review by Peter.
> >
> > ------------------------------
> >
> > Fix a bug with cloning thread local mutables.
> >
> > In low-level C parallel grades, we clone the thread local mutables array when
> > we spawn a new thread. Access to this array is protected by a mutex. The
> > runtime code responsible for cloning the array acquires the lock for the
> > new copy of the array to which values are being written, instead of the old
> > copy, from which values are being read. It is the latter which needs to
> > be protected by mutex, not the former. (There are no other references to
> > the new mutables array at the point it is cloned.)
> >
> > runtime/mercury_thread.[ch]:
> > Acquire the mutex for the copy of the thread local mutables we
> > are reading from, not writing to.
> >
> > Delete the const qualifier from the argument of
> > MR_clone_thread_local_mutables(), as acquiring the mutex will
> > modify it.
> >
> > Julien.
> >
>
> Oops! Thanks.
Thanks. Pushed along with the additional comment Zoltan requested.
Julien.
More information about the reviews
mailing list