1
1

* test for condition where we think we can intercept malloc/free/munmap but

really can't.  Test for munmap, since it's the most likely to cause problems,
  since it's always an interposed symbol.

  The condition that usually causes problems is if libmpi was brought in as
  the result of a library dependency, rather than as a -l on the link line.
  The linker in this case will find malloc/free/munmap/etc. in libc, rather
  than in libmpi.

This commit was SVN r7508.
Этот коммит содержится в:
Brian Barrett 2005-09-26 20:20:20 +00:00
родитель d9e80d8f2a
Коммит 1d9b663b62
3 изменённых файлов: 24 добавлений и 6 удалений

Просмотреть файл

@ -51,11 +51,11 @@ opal_memory_malloc_hooks_init(void)
}
initialized = 1;
opal_mem_free_set_free_support(1);
old_free_hook = __free_hook;
old_realloc_hook = __realloc_hook;
__free_hook = opal_mem_free_free_hook;
__realloc_hook = opal_mem_free_realloc_hook;
opal_mem_free_set_free_support(1);
}

Просмотреть файл

@ -17,7 +17,9 @@
#include "ompi_config.h"
#include <sys/types.h>
#include <sys/mman.h>
#include "opal/util/output.h"
#include "opal/memory/memory.h"
#include "opal/memory/memory_internal.h"
#include "opal/class/opal_list.h"
@ -43,7 +45,7 @@ static opal_list_t callback_list;
static opal_atomic_lock_t callback_lock;
static int have_free_support = false;
static int run_callbacks = false;
static int have_been_called = 0;
int
opal_mem_free_init(void)
@ -56,6 +58,20 @@ opal_mem_free_init(void)
run_callbacks = false;
opal_atomic_mb();
/* make sure that things really work - we munmap something that
won't matter (a NULL, 0 pair) and see if have_been_called flips
from 0 to 1. If so, we're all good. */
munmap(NULL, 0);
if (0 == have_been_called) {
if (have_free_support) {
opal_output(0, "WARNING: free() and munmap() hooks inoperative"
"disabling memory hooks. This");
opal_output(0, "WARNING: may cause performance degredation.");
}
have_free_support = false;
}
return OMPI_SUCCESS;
}
@ -70,7 +86,7 @@ opal_mem_free_finalize(void)
/* aquire the lock, just to make sure no one is currently
twiddling with the list. We know this won't last long, since
no new calls will come in twiddle with the list */
no new calls will come in after we set run_callbacks to false */
opal_atomic_lock(&callback_lock);
while (NULL != (item = opal_list_remove_first(&callback_list))) {
@ -98,6 +114,8 @@ opal_mem_free_release_hook(void *buf, size_t length)
{
opal_list_item_t *item;
have_been_called = 1;
if (!run_callbacks) return;
/*

Просмотреть файл

@ -79,9 +79,6 @@ int opal_init(void)
/* init the trace function */
opal_trace_init();
/* initialize the memory manager / tracker */
opal_mem_free_init();
/* register handler for errnum -> string converstion */
opal_error_register("OPAL", OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str);
@ -98,6 +95,9 @@ int opal_init(void)
without good initialization routine support */
opal_memory_base_open();
/* initialize the memory manager / tracker */
opal_mem_free_init();
opal_timer_base_open();
return OPAL_SUCCESS;