mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Improved error diagnostics for memory overflow.
This commit is contained in:
@@ -67,8 +67,15 @@ static inline void* mmap_allocate(Vmem *vmem, size_t to_allocate)
|
|||||||
void *res = VirtualAlloc(((char*)vmem->ptr) + vmem->committed, to_commit, MEM_COMMIT, PAGE_READWRITE);
|
void *res = VirtualAlloc(((char*)vmem->ptr) + vmem->committed, to_commit, MEM_COMMIT, PAGE_READWRITE);
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
|
if (to_allocate < 0x1000)
|
||||||
|
{
|
||||||
|
error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
|
||||||
|
"exceeding the current maximum limit. Perhaps you called some recursive macro?",
|
||||||
|
(unsigned)(allocated_after / (1024 * 1024)));
|
||||||
|
}
|
||||||
error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
|
error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
|
||||||
"which was rejected. Perhaps you called some recursive macro?", (unsigned)(allocated_after / (1024 * 1024)));
|
"exceeding the current maximum limit. The last allocation was for %llu bytes.",
|
||||||
|
(unsigned)(allocated_after / (1024 * 1024)), (unsigned long long)to_allocate);
|
||||||
}
|
}
|
||||||
vmem->committed += to_commit;
|
vmem->committed += to_commit;
|
||||||
}
|
}
|
||||||
@@ -77,9 +84,15 @@ static inline void* mmap_allocate(Vmem *vmem, size_t to_allocate)
|
|||||||
vmem->allocated = allocated_after;
|
vmem->allocated = allocated_after;
|
||||||
if (vmem->size < allocated_after)
|
if (vmem->size < allocated_after)
|
||||||
{
|
{
|
||||||
|
if (to_allocate < 0x1000)
|
||||||
|
{
|
||||||
|
error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
|
||||||
|
"exceeding the current maximum limit. Perhaps you called some recursive macro?",
|
||||||
|
(unsigned)(vmem->size / (1024 * 1024)));
|
||||||
|
}
|
||||||
error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
|
error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
|
||||||
"exceeding the current maximum limit. Perhaps you called some recursive macro?",
|
"exceeding the current maximum limit. The last allocation was for %llu bytes.",
|
||||||
(unsigned)(vmem->size / (1024 * 1024)));
|
(unsigned)(vmem->size / (1024 * 1024)), (unsigned long long)to_allocate);
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user