From 95a5802c1afc9a0f515d1ecf90b294b31cf2e36e Mon Sep 17 00:00:00 2001 From: Jon Purdy Date: Mon, 11 May 2015 15:25:24 -0700 Subject: [PATCH] [sgen] Move & document write barrier. --- mono/sgen/sgen-gchandles.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mono/sgen/sgen-gchandles.c b/mono/sgen/sgen-gchandles.c index b18a65afa82..3fb721e39f9 100644 --- a/mono/sgen/sgen-gchandles.c +++ b/mono/sgen/sgen-gchandles.c @@ -231,11 +231,14 @@ handle_data_grow (HandleData *handles, guint32 old_capacity) entries = g_malloc0 (new_bucket_size); if (handles->type == HANDLE_PINNED) sgen_register_root ((char *)entries, new_bucket_size, SGEN_DESCRIPTOR_NULL, ROOT_TYPE_PINNED, MONO_ROOT_SOURCE_GC_HANDLE, "pinned gc handles"); + /* The zeroing of the newly allocated bucket must be complete before storing + * the new bucket pointer. + */ + mono_memory_write_barrier (); if (InterlockedCompareExchangePointer ((volatile gpointer *)&handles->entries [new_bucket], entries, NULL) == NULL) { if (InterlockedCompareExchange ((volatile gint32 *)&handles->capacity, new_capacity, old_capacity) != old_capacity) g_assert_not_reached (); handles->slot_hint = old_capacity; - mono_memory_write_barrier (); return; } /* Someone beat us to the allocation. */ -- 2.25.1