Skip to content

Commit b62f455

Browse files
committed
Fix publishing of compressed bitmap
Before this commit we were doing changes on the published data which is problematic for multithreaded environments. We ensure the bitmap is fully processed before publishing it so that we can rely on the data dependency memory ordering constraint for correctness.
1 parent 92c7d70 commit b62f455

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/mono/mono/metadata/class-setup-vtable.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,12 @@ mono_class_setup_interface_offsets_internal (MonoClass *klass, int cur_slot, int
346346
}
347347
if (!klass->interface_bitmap) {
348348
#ifdef COMPRESSED_INTERFACE_BITMAP
349-
int i = mono_compress_bitmap (NULL, bitmap, bsize);
350-
klass->interface_bitmap = mono_class_alloc0 (klass, i);
351-
mono_compress_bitmap (klass->interface_bitmap, bitmap, bsize);
349+
int len = mono_compress_bitmap (NULL, bitmap, bsize);
350+
uint8_t *compressed_bitmap = mono_class_alloc0 (klass, len);
351+
mono_compress_bitmap (compressed_bitmap, bitmap, bsize);
352352
g_free (bitmap);
353+
354+
klass->interface_bitmap = compressed_bitmap;
353355
#else
354356
klass->interface_bitmap = bitmap;
355357
#endif

0 commit comments

Comments
 (0)