Skip to content

Commit a006c8d

Browse files
committed
Avoid overflow with ephemerons (case UUM-25411)
Use GC_mark_and_push to safely push object for marking.
1 parent bdcb2e1 commit a006c8d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

external/bdwgc

mono/metadata/boehm-gc.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ mono_push_other_roots(void);
7373

7474
static void
7575
mono_clear_ephemerons (void);
76-
static void
77-
mono_push_ephemerons (void);
76+
static struct GC_ms_entry*
77+
mono_push_ephemerons(struct GC_ms_entry* mark_stack_ptr, struct GC_ms_entry* mark_stack_limit);
7878
static void*
7979
null_ephemerons_for_domain (MonoDomain* domain);
8080

@@ -2121,8 +2121,8 @@ mono_clear_ephemerons (void)
21212121
}
21222122
}
21232123

2124-
static void
2125-
mono_push_ephemerons (void)
2124+
static struct GC_ms_entry*
2125+
mono_push_ephemerons (struct GC_ms_entry* mark_stack_ptr, struct GC_ms_entry* mark_stack_limit)
21262126
{
21272127
ephemeron_node* prev_node = NULL;
21282128
ephemeron_node* current_node = NULL;
@@ -2155,12 +2155,13 @@ mono_push_ephemerons (void)
21552155
if (!GC_is_marked (current_ephemeron->key))
21562156
continue;
21572157

2158-
if (current_ephemeron->value && !GC_is_marked (current_ephemeron->value)) {
2159-
/* the key is marked, so mark the value if needed */
2160-
GC_push_all (&current_ephemeron->value, &current_ephemeron->value + 1);
2158+
if (current_ephemeron->value) {
2159+
mark_stack_ptr = GC_mark_and_push(current_ephemeron->value, mark_stack_ptr, mark_stack_limit, &current_ephemeron->value);
21612160
}
21622161
}
21632162
}
2163+
2164+
return mark_stack_ptr;
21642165
}
21652166

21662167
static void*

0 commit comments

Comments
 (0)