[m-rev.] for review: fix a bug with cloning thread local mutables

Zoltan Somogyi zoltan.somogyi at runbox.com
Tue Oct 13 22:25:26 AEDT 2026



On Tue, 13 Oct 2026 22:18:55 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> For review by Peter.

I am not Peter, and I have never worked on thread-related stuff,
but I would take this explanation:

> 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.)

... and add it as a comment ...

> -    MR_LOCK(&new_muts->MR_tlm_lock, "MR_clone_thread_local_mutables");
> +    MR_LOCK(&old_muts->MR_tlm_lock, "MR_clone_thread_local_mutables");
>      for (MR_Unsigned i = 0; i < MR_num_thread_local_mutables; i++) {
>          new_muts->MR_tlm_values[i] = old_muts->MR_tlm_values[i];
>      }
> -    MR_UNLOCK(&new_muts->MR_tlm_lock, "MR_clone_thread_local_mutables");
> +    MR_UNLOCK(&old_muts->MR_tlm_lock, "MR_clone_thread_local_mutables");

... before this block of code. (After replacing "the latter" part.)

Zoltan.





More information about the reviews mailing list