mirror of
https://github.com/golang/go
synced 2024-11-22 16:25:07 -07:00
runtime: correct out of memory error
Fixes #1511. R=golang-dev, iant2 CC=golang-dev https://golang.org/cl/4433065
This commit is contained in:
parent
4efdeeec51
commit
a8bf6f32cc
@ -36,6 +36,11 @@ runtime·SysReserve(void *v, uintptr n)
|
|||||||
return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENOMEM = 12,
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·SysMap(void *v, uintptr n)
|
runtime·SysMap(void *v, uintptr n)
|
||||||
{
|
{
|
||||||
@ -43,6 +48,8 @@ runtime·SysMap(void *v, uintptr n)
|
|||||||
|
|
||||||
mstats.sys += n;
|
mstats.sys += n;
|
||||||
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
||||||
|
if(p == (void*)-ENOMEM)
|
||||||
|
runtime·throw("runtime: out of memory");
|
||||||
if(p != v)
|
if(p != v)
|
||||||
runtime·throw("runtime: cannot map pages in arena address space");
|
runtime·throw("runtime: cannot map pages in arena address space");
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,11 @@ runtime·SysReserve(void *v, uintptr n)
|
|||||||
return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENOMEM = 12,
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·SysMap(void *v, uintptr n)
|
runtime·SysMap(void *v, uintptr n)
|
||||||
{
|
{
|
||||||
@ -52,6 +57,8 @@ runtime·SysMap(void *v, uintptr n)
|
|||||||
// On 64-bit, we don't actually have v reserved, so tread carefully.
|
// On 64-bit, we don't actually have v reserved, so tread carefully.
|
||||||
if(sizeof(void*) == 8) {
|
if(sizeof(void*) == 8) {
|
||||||
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
|
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||||
|
if(p == (void*)-ENOMEM)
|
||||||
|
runtime·throw("runtime: out of memory");
|
||||||
if(p != v) {
|
if(p != v) {
|
||||||
runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p);
|
runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p);
|
||||||
runtime·throw("runtime: address space conflict");
|
runtime·throw("runtime: address space conflict");
|
||||||
@ -60,6 +67,8 @@ runtime·SysMap(void *v, uintptr n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
||||||
|
if(p == (void*)-ENOMEM)
|
||||||
|
runtime·throw("runtime: out of memory");
|
||||||
if(p != v)
|
if(p != v)
|
||||||
runtime·throw("runtime: cannot map pages in arena address space");
|
runtime·throw("runtime: cannot map pages in arena address space");
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,11 @@ runtime·SysReserve(void *v, uintptr n)
|
|||||||
return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENOMEM = 12,
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·SysMap(void *v, uintptr n)
|
runtime·SysMap(void *v, uintptr n)
|
||||||
{
|
{
|
||||||
@ -66,6 +71,8 @@ runtime·SysMap(void *v, uintptr n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
||||||
|
if(p == (void*)-ENOMEM)
|
||||||
|
runtime·throw("runtime: out of memory");
|
||||||
if(p != v)
|
if(p != v)
|
||||||
runtime·throw("runtime: cannot map pages in arena address space");
|
runtime·throw("runtime: cannot map pages in arena address space");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user