Skip to content

Fail to get_free_region in thread_final_regions due to low memory for mark array might lead to AV. #74401

@cshung

Description

@cshung

While our logic guarantee a free region is available in the free region list before thread_final_regions, in case we are running out of memory to commit for the mark array, the call to init_table_for_region called in get_free_region may fail and therefore return nullptr.

To reproduce the issue, we can run GCPerfSim with these parameters:

GCPerfSim.dll -tc 6 -tagb 100.0 -tlgb 0.2 -lohar 0 -pohar 0 -sohsi 10 -lohsi 0 -pohsi 0 -sohsr 100-4000 -lohsr 102400-204800 -pohsr 100-4000 -sohpi 10 -lohpi 0 -sohfi 0 -lohfi 0 -pohfi 0 -allocType reference -testKind time

and these environment variables:

COMPlus_GCHeapCount=6
COMPlus_GCHeapHardLimit=1C200000
COMPlus_GCServer=1

On this commit 5f80c24 with a simple change to replace this line in sufficient_space_regions

return check_against_hard_limit (end_space_required);

to

return true;

The change was made to make this easier to repro only and is not an intended product change.

To make this issue easier to identify, we can add a check after get_free_region in thread_final_regions as follow. Change

start_region = get_free_region (gen_idx);

to

start_region = get_free_region (gen_idx);
if (start_region == nullptr) { FATAL_GC_ERROR(); }

The process will fail at the spot. Without the check, the nullptr might be threaded into the generation, and will lead to bad consequences (such as an AV).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions