From 8a2df3311dbaf6551586c353bae745f615f71482 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 28 Mar 2012 16:41:29 +0000 Subject: [PATCH] Fixes trac:2812: check for env. markers indicating that we're in a fakeroot. If so, exit out of the pre-main hook immediately (without calling functions such as stat, which will be replaced by fakeroot to things that are not safe to call in a pre-main environment). This commit was SVN r26203. The following Trac tickets were found above: Ticket 2812 --> https://svn.open-mpi.org/trac/ompi/ticket/2812 --- opal/mca/memory/linux/hooks.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/opal/mca/memory/linux/hooks.c b/opal/mca/memory/linux/hooks.c index 973f21435e..ed771c1102 100644 --- a/opal/mca/memory/linux/hooks.c +++ b/opal/mca/memory/linux/hooks.c @@ -738,7 +738,17 @@ static void opal_memory_linux_malloc_init_hook(void) check_result_t r1, r2, lp, lpp; bool want_rcache = false, found_driver = false; - /* First, check if ummunotify is present on the system. If it is, + /* First, check for a FAKEROOT environment. If we're in a + fakeroot, then stat() (and likely others) have been replaced + and are not safe to call here in this pre-main environment. So + check for the environment markers that we're in a FAKEROOT. + And if so, return immediately. */ + if (getenv("FAKEROOTKEY") != NULL || + getenv("FAKE_ROOT_MODE") != NULL) { + return; + } + + /* Next, check if ummunotify is present on the system. If it is, then we don't need to do the following ptmalloc2 hacks. open/mmap on the device may fail during init, but if /dev/ummunotify exists, we assume that the user/administrator *wants* to use