Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 43c102e

Browse files
committed
Fixed race condition in setting dd_new_allocation
Sequence: + At the end of BGC we call compute_new_dynamic_data then switch to preempt, at this point dd_new_allocation isn't set yet; + an FGC happens and saves new_allocation in gc_new_allocation + FGC finishes and BGC keeps running and saves gc_new_allocation in new_allocation The fix is to finish filling in the values for new_allocations before we allow an FGC to happen. Should really get rid of gc_new_allocation in the future. I am making this fix to unblock my work on the fragmentation stuff.
1 parent adb2188 commit 43c102e

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/gc/gc.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15342,21 +15342,6 @@ void gc_heap::gc1()
1534215342
assert (ephemeral_high == heap_segment_reserved (ephemeral_heap_segment));
1534315343
#endif //BACKGROUND_GC
1534415344

15345-
int bottom_gen = 0;
15346-
#ifdef BACKGROUND_GC
15347-
if (settings.concurrent)
15348-
{
15349-
bottom_gen = max_generation;
15350-
}
15351-
#endif //BACKGROUND_GC
15352-
{
15353-
for (int gen_number = bottom_gen; gen_number <= max_generation+1; gen_number++)
15354-
{
15355-
dynamic_data* dd = dynamic_data_of (gen_number);
15356-
dd_new_allocation(dd) = dd_gc_new_allocation (dd);
15357-
}
15358-
}
15359-
1536015345
if (fgn_maxgen_percent)
1536115346
{
1536215347
if (settings.condemned_generation == (max_generation - 1))
@@ -29848,6 +29833,7 @@ size_t gc_heap::compute_in (int gen_number)
2984829833
}
2984929834

2985029835
dd_gc_new_allocation (dd) -= in;
29836+
dd_new_allocation (dd) = dd_gc_new_allocation (dd);
2985129837

2985229838
gc_history_per_heap* current_gc_data_per_heap = get_gc_data_per_heap();
2985329839
gc_generation_data* gen_data = &(current_gc_data_per_heap->gen_data[gen_number]);
@@ -30020,6 +30006,8 @@ void gc_heap::compute_new_dynamic_data (int gen_number)
3002030006
gen_data->npinned_surv = dd_survived_size (dd) - dd_pinned_survived_size (dd);
3002130007

3002230008
dd_gc_new_allocation (dd) = dd_desired_allocation (dd);
30009+
dd_new_allocation (dd) = dd_gc_new_allocation (dd);
30010+
3002330011
//update counter
3002430012
dd_promoted_size (dd) = out;
3002530013
if (gen_number == max_generation)
@@ -30035,6 +30023,7 @@ void gc_heap::compute_new_dynamic_data (int gen_number)
3003530023
dd_desired_allocation (dd) = desired_new_allocation (dd, out, max_generation+1, 0);
3003630024
dd_gc_new_allocation (dd) = Align (dd_desired_allocation (dd),
3003730025
get_alignment_constant (FALSE));
30026+
dd_new_allocation (dd) = dd_gc_new_allocation (dd);
3003830027

3003930028
gen_data = &(current_gc_data_per_heap->gen_data[max_generation+1]);
3004030029
gen_data->size_after = total_gen_size;

0 commit comments

Comments
 (0)