1
1

* with ptmalloc2, prefer syscall over dlsym for calling the real munmap. This

makes illegal free() calls behave in a much more rational way.  You'll still
  probably die, but your stack trace will not have 3 billion pages of recusion
  inside the memory allocator.
* Fix illegal free in the opal_wrapper code.  basename() returns a string in a
  static buffer, so it shouldn't be free()ed.  It also shouldn't be left around
  so long, as another call to basename() may whack the returned buffer.  So
  leave the free and add a strdup() around the basename() call.
* Turn off some unneeded debugging in the opal_wrapper code that would list the
  comamnd to be run, regardless of the -showme option.

This commit was SVN r8758.
Этот коммит содержится в:
Brian Barrett 2006-01-19 18:48:58 +00:00
родитель ee9b31459b
Коммит 5e6798cb4d
2 изменённых файлов: 10 добавлений и 10 удалений

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

@ -22,15 +22,15 @@
#include <stdlib.h>
#include <sys/mman.h>
#if defined(HAVE___MUNMAP)
/* here so we only include dlfcn if we absolutely have to */
/* here so we only include others if we absolutely have to */
#elif defined(HAVE_SYSCALL)
#include <syscall.h>
#include <unistd.h>
#elif defined(HAVE_DLSYM)
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include <dlfcn.h>
#elif defined(HAVE_SYSCALL)
#include <syscall.h>
#include <unistd.h>
#endif
#include "opal/memoryhooks/memory_internal.h"
@ -59,7 +59,7 @@ munmap(void* addr, size_t len)
int
opal_mem_free_ptmalloc2_munmap(void *start, size_t length, int from_alloc)
{
#if !defined(HAVE___MUNMAP) && defined(HAVE_DLSYM)
#if !defined(HAVE___MUNMAP) && !defined(HAVE_SYSCALL) && defined(HAVE_DLSYM)
static int (*realmunmap)(void*, size_t);
#endif
@ -67,6 +67,8 @@ opal_mem_free_ptmalloc2_munmap(void *start, size_t length, int from_alloc)
#if defined(HAVE___MUNMAP)
return __munmap(start, length);
#elif defined(HAVE_SYSCALL)
return syscall(__NR_munmap, start, length);
#elif defined(HAVE_DLSYM)
if (NULL == realmunmap) {
union {
@ -79,8 +81,6 @@ opal_mem_free_ptmalloc2_munmap(void *start, size_t length, int from_alloc)
}
return realmunmap(start, length);
#elif defined(HAVE_SYSCALL)
return syscall(__NR_munmap, start, length);
#else
#error "Can not determine how to call munmap"
#endif

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

@ -272,7 +272,7 @@ main(int argc, char *argv[])
int exit_status = 0, ret, flags = 0, i;
int exec_argc = 0, user_argc = 0;
char **exec_argv = NULL, **user_argv = NULL;
char *exec_command, *base_argv0;
char *exec_command, *base_argv0 = NULL;
bool disable_flags = true;
bool real_flag = false;
@ -287,7 +287,7 @@ main(int argc, char *argv[])
*
****************************************************/
base_argv0 = basename(argv[0]);
base_argv0 = strdup(basename(argv[0]));
if (OPAL_SUCCESS != (ret = data_init(base_argv0))) {
return ret;
}
@ -511,7 +511,7 @@ main(int argc, char *argv[])
} else {
char *tmp;
#if 1
#if 0
exec_command = opal_argv_join(exec_argv, ' ');
printf("command: %s\n", exec_command);
#endif