Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAL/Linux] Log a message on mmap() returning -ENOMEM #2023

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pal/src/host/linux/pal_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ int _PalVirtualMemoryAlloc(void* addr, size_t size, pal_prot_flags_t prot) {
void* res_addr = (void*)DO_SYSCALL(mmap, addr, size, linux_prot, flags, -1, 0);

if (IS_PTR_ERR(res_addr)) {
return unix_to_pal_error(PTR_TO_ERR(res_addr));
int ret = PTR_TO_ERR(res_addr);
if (ret == -ENOMEM && FIRST_TIME()) {
log_debug("Host Linux returned -ENOMEM on mmap(); this may happen because process's "
"maximum number of mappings would be exceeded. Gramine cannot handle this "
"case. You may want to increase the value in /proc/sys/vm/max_map_count.");
}

return unix_to_pal_error(ret);
}

assert(res_addr == addr);
Expand All @@ -50,7 +57,7 @@ int _PalVirtualMemoryFree(void* addr, size_t size) {
int ret = DO_SYSCALL(munmap, addr, size);
if (ret == -ENOMEM && FIRST_TIME()) {
log_error("Host Linux returned -ENOMEM on munmap(); this may happen because process's "
"maximum number of mappings is exceeded. Gramine cannot handle this case. "
"maximum number of mappings would be exceeded. Gramine cannot handle this case. "
"You may want to increase the value in /proc/sys/vm/max_map_count.");
}
return ret < 0 ? unix_to_pal_error(ret) : 0;
Expand Down