[interp] Use existing InterpMethod if allocation and lookup race (#57985)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 24 Aug 2021 19:27:13 +0000 (15:27 -0400)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 19:27:13 +0000 (15:27 -0400)
commit949a0a0c36e7704e68aeebd576d4a9b64bf42211
treef40bb07eb22d35fb93ceb094de9db65c090efd89
parent1316a45651f2f4bf0f5fb062f103eb03e5e170fb
[interp] Use existing InterpMethod if allocation and lookup race (#57985)

If two threads both want to get an InterpMethod for the same MonoMethod, and
they both see null from the first hash table lookup, make sure that whichever
one comes into the jit_mm lock second re-uses the previously inserted
InterpMethod, instead of its own version.

Without this change, racing threads will overwrite
MonoJitInfo:seq_points (in mono_interp_transform_method) which sometimes leads
to deallocating the same sequence points multiple times.

Fixes https://github.com/dotnet/runtime/issues/57812

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
src/mono/mono/mini/interp/interp.c