forked from google/gvisor
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow to make allocations large than 64MB. Signed-off-by: Andrei Vagin <[email protected]>
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go | ||
index 44479cc2be..adcee90992 100644 | ||
--- a/src/runtime/malloc.go | ||
+++ b/src/runtime/malloc.go | ||
@@ -946,6 +946,9 @@ func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bo | ||
// Small objects are allocated from the per-P cache's free lists. | ||
// Large objects (> 32 kB) are allocated straight from the heap. | ||
func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { | ||
+ if size > (64 << 20) { | ||
+ throw("large allocation") | ||
+ } | ||
if gcphase == _GCmarktermination { | ||
throw("mallocgc called with gcphase == _GCmarktermination") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters