Skip to content

Commit

Permalink
Clear entries referencing the domain in reference_queue_clear_for_dom…
Browse files Browse the repository at this point in the history
…ain () even if the object is already null. Fixes #4595.
  • Loading branch information
vargaz committed May 17, 2013
1 parent 0a2d193 commit 7e95cf9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions mono/metadata/gc-internal.h
Expand Up @@ -339,6 +339,7 @@ struct _RefQueueEntry {
#else
guint32 gchandle;
#endif
MonoDomain *domain;
void *user_data;
RefQueueEntry *next;
};
Expand Down
6 changes: 2 additions & 4 deletions mono/metadata/gc.c
Expand Up @@ -1396,13 +1396,10 @@ reference_queue_clear_for_domain (MonoDomain *domain)
RefQueueEntry *entry;
while ((entry = *iter)) {
MonoObject *obj;
if (entry->domain == domain) {
#ifdef HAVE_SGEN_GC
obj = mono_gc_weak_link_get (&entry->dis_link);
if (obj && mono_object_domain (obj) == domain) {
mono_gc_weak_link_remove (&entry->dis_link, TRUE);
#else
obj = mono_gchandle_get_target (entry->gchandle);
if (obj && mono_object_domain (obj) == domain) {
mono_gchandle_free ((guint32)entry->gchandle);
#endif
ref_list_remove_element (iter, entry);
Expand Down Expand Up @@ -1458,6 +1455,7 @@ mono_gc_reference_queue_add (MonoReferenceQueue *queue, MonoObject *obj, void *u

entry = g_new0 (RefQueueEntry, 1);
entry->user_data = user_data;
entry->domain = mono_object_domain (obj);

#ifdef HAVE_SGEN_GC
mono_gc_weak_link_add (&entry->dis_link, obj, TRUE);
Expand Down

0 comments on commit 7e95cf9

Please sign in to comment.