Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: src/trusted/service_runtime/arch/x86_64/sel_addrspace_posix_x86_64.c

Issue 10823018: Add a developer hint log message for when RLIMIT_AS is the culprint in startup failure. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/arch/x86_64/sel_addrspace_posix_x86_64.c
===================================================================
--- src/trusted/service_runtime/arch/x86_64/sel_addrspace_posix_x86_64.c (revision 9237)
+++ src/trusted/service_runtime/arch/x86_64/sel_addrspace_posix_x86_64.c (working copy)
@@ -6,6 +6,12 @@
#include <errno.h>
#include <sys/mman.h>
+#if NACL_LINUX
+/*
+ * For getrlimit.
+ */
+# include <sys/resource.h>
+#endif
#include "native_client/src/include/nacl_platform.h"
#include "native_client/src/shared/platform/nacl_check.h"
@@ -111,6 +117,9 @@
NACL_ADDRSPACE_UPPER_GUARD_SIZE);
size_t log_align = ALIGN_BITS;
void *mem_ptr;
+#if NACL_LINUX
+ struct rlimit rlim;
+#endif
NaClLog(4, "NaClAllocateSpace(*, 0x%016"NACL_PRIxS" bytes).\n",
addrsp_size);
@@ -126,6 +135,47 @@
perror("NaClAllocatePow2AlignedMemory");
}
NaClLog(LOG_WARNING, "Memory allocation failed\n");
+#if NACL_LINUX
+ /*
+ * Check with getrlimit whether RLIMIT_AS was likely to be the
+ * problem with an allocation failure. If so, generate a log
+ * message. Since this is a debugging aid and we don't know about
+ * the memory requirement of the code that is embedding native
+ * client, there is some slop.
+ */
+ if (0 != getrlimit(RLIMIT_AS, &rlim)) {
+ perror("NaClAllocatePow2AlignedMemory::getrlimit");
+ } else {
+ if (rlim.rlim_cur < mem_sz) {
+ /*
+ * Developer hint/warning; this will show up in the crash log
+ * and must be brief.
+ */
+ NaClLog(LOG_INFO,
+ "Please run \"ulimit -v unlimited\" (bash)"
Brad Chen 2012/07/25 20:28:09 If we do a lot of these user-facing messages, we m
+ " or \"limit vmemoryuse unlimited\" (tcsh)\n");
+ NaClLog(LOG_INFO,
+ "and restart the app. NaCl requires at least %"NACL_PRIdS""
+ " kilobytes of virtual\n",
+ mem_sz / 1024);
+ NaClLog(LOG_INFO,
+ "address space. NB: Raising the hard limit requires"
+ " root access.\n");
+ }
+ }
+#elif NACL_OSX
+ /*
+ * In OSX, RLIMIT_AS and RLIMIT_RSS have the same value; i.e., OSX
+ * conflates the notion of virtual address space used with the
+ * resident set size. In particular, the way NaCl uses virtual
+ * address space is to allocate guard pages so that certain
+ * addressing modes will not need to be explicitly masked; the
+ * guard pages are allocated but inaccessible, never faulted so
+ * not even zero-filled on demand, so they should not count
+ * against the resident set -- which is supposed to be only the
+ * frequently accessed pages in the first place.
+ */
+#endif
return LOAD_NO_MEMORY;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698