Skip to content

Commit 5828aef

Browse files
authored
[sanitizer_common] Return nullptr from ASan on ERROR_COMMITMENT_LIMIT (#119753)
Followup to #117929
1 parent ea44647 commit 5828aef

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static void *ReturnNullptrOnOOMOrDie(uptr size, const char *mem_type,
167167

168168
// Assumption: VirtualAlloc is the last system call that was invoked before
169169
// this method.
170-
// VirtualAlloc emits one of 2 error codes when running out of memory
170+
// VirtualAlloc emits one of 3 error codes when running out of memory
171171
// 1. ERROR_NOT_ENOUGH_MEMORY:
172172
// There's not enough memory to execute the command
173173
// 2. ERROR_INVALID_PARAMETER:
@@ -176,12 +176,12 @@ static void *ReturnNullptrOnOOMOrDie(uptr size, const char *mem_type,
176176
// (the `lpMaximumApplicationAddress` field within the `SystemInfo` struct).
177177
// This does not seem to be officially documented, but is corroborated here:
178178
// https://stackoverflow.com/questions/45833674/why-does-virtualalloc-fail-for-lpaddress-greater-than-0x6ffffffffff
179-
180-
// Note - It's possible that 'ERROR_COMMITMENT_LIMIT' needs to be handled here
181-
// as well. It is currently not handled due to the lack of a reproducer that
182-
// induces the error code.
179+
// 3. ERROR_COMMITMENT_LIMIT:
180+
// VirtualAlloc will return this if e.g. the pagefile is too small to commit
181+
// the requested amount of memory.
183182
if (last_error == ERROR_NOT_ENOUGH_MEMORY ||
184-
last_error == ERROR_INVALID_PARAMETER)
183+
last_error == ERROR_INVALID_PARAMETER ||
184+
last_error == ERROR_COMMITMENT_LIMIT)
185185
return nullptr;
186186
ReportMmapFailureAndDie(size, mem_type, mmap_type, last_error);
187187
}

0 commit comments

Comments
 (0)