@@ -113,6 +113,24 @@ class SizeClassAllocator64 {
113113 // ~(uptr)0.
114114 void Init (s32 release_to_os_interval_ms, uptr heap_start = 0 ) {
115115 uptr TotalSpaceSize = kSpaceSize + AdditionalSize ();
116+
117+ uptr MaxAddr = GetMaxUserVirtualAddress ();
118+ // VReport does not call the sanitizer allocator.
119+ VReport (3 , " Max user virtual address: 0x%zx\n " , MaxAddr);
120+ VReport (3 , " Total space size for primary allocator: 0x%zx\n " ,
121+ TotalSpaceSize);
122+ // TODO: revise the check if we ever configure sanitizers to deliberately
123+ // map beyond the 2**48 barrier (note that Linux pretends the VMA is
124+ // limited to 48-bit for backwards compatibility, but allows apps to
125+ // explicitly specify an address beyond that).
126+ if (heap_start + TotalSpaceSize >= MaxAddr) {
127+ // We can't easily adjust the requested heap size, because kSpaceSize is
128+ // const (for optimization) and used throughout the code.
129+ VReport (0 , " Error: heap size %zx exceeds max user virtual address %zx\n " ,
130+ TotalSpaceSize, MaxAddr);
131+ VReport (
132+ 0 , " Try using a kernel that allows a larger virtual address space\n " );
133+ }
116134 PremappedHeap = heap_start != 0 ;
117135 if (PremappedHeap) {
118136 CHECK (!kUsingConstantSpaceBeg );
0 commit comments