(vtable): ... this new file static variable split out from ...
(get_vtable): ... here. Initialize vtable, register vl_exit as
dlloader_exit function.
* libltdl/loaders/dlopen.c: Likewise.
* libltdl/loaders/dyld.c: Likewise.
* libltdl/loaders/load_add_on.c: Likewise.
* libltdl/loaders/loadlibrary.c: Likewise.
* libltdl/loaders/shl_load.c: Likewise.
* libltdl/loaders/preopen.c: Likewise; vl_exit existed here
already.
* tests/lt_dlexit.at (lt_dlexit unloading libs): Update test.
* NEWS: Update.
Report by Andreas Schwab.
+2008-03-04 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * libltdl/loaders/dld_link.c (vl_exit): New function, zero out ...
+ (vtable): ... this new file static variable split out from ...
+ (get_vtable): ... here. Initialize vtable, register vl_exit as
+ dlloader_exit function.
+ * libltdl/loaders/dlopen.c: Likewise.
+ * libltdl/loaders/dyld.c: Likewise.
+ * libltdl/loaders/load_add_on.c: Likewise.
+ * libltdl/loaders/loadlibrary.c: Likewise.
+ * libltdl/loaders/shl_load.c: Likewise.
+ * libltdl/loaders/preopen.c: Likewise; vl_exit existed here
+ already.
+ * tests/lt_dlexit.at (lt_dlexit unloading libs): Update test.
+ * NEWS: Update.
+ Report by Andreas Schwab.
+
2008-03-01 Gary V. Vaughan <gary@gnu.org>
* configure.ac, libltdl/configure.ac (AC_INIT): Bump version
New in 2.3b: 2008-??-??: CVS version 2.3a, Libtool team:
-* Nothing yet!
+* Bug fixes:
+
+ - Fix 2.2 regression in libltdl that causes memory corruption upon
+ repeated `lt_dlinit(); lt_dlexit()'.
New in 2.2: 2008-03-01; CVS version 2.1c, Libtool team:
/* loader-dld_link.c -- dynamic linking with dld
Copyright (C) 1998, 1999, 2000, 2004, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Thomas Tanner, 1998
NOTE: The canonical source of this file is maintained with the
/* Boilerplate code to set up the vtable for hooking this loader into
libltdl's loader list: */
+static int vl_exit (lt_user_data loader_data);
static lt_module vm_open (lt_user_data loader_data, const char *filename,
lt_dladvise advise);
static int vm_close (lt_user_data loader_data, lt_module module);
static void * vm_sym (lt_user_data loader_data, lt_module module,
const char *symbolname);
+static lt_dlvtable *vtable = 0;
+
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
change between loaders. */
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = lt__zalloc (sizeof *vtable);
vtable->module_open = vm_open;
vtable->module_close = vm_close;
vtable->find_sym = vm_sym;
+ vtable->dlloader_exit = vl_exit;
vtable->dlloader_data = loader_data;
vtable->priority = LT_DLLOADER_APPEND;
}
# include <dld.h>
#endif
+/* A function called through the vtable when this loader is no
+ longer needed by the application. */
+static int
+vl_exit (lt_user_data LT__UNUSED loader_data)
+{
+ vtable = NULL;
+ return 0;
+}
+
/* A function called through the vtable to open a module with this
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
/* Boilerplate code to set up the vtable for hooking this loader into
libltdl's loader list: */
+static int vl_exit (lt_user_data loader_data);
static lt_module vm_open (lt_user_data loader_data, const char *filename,
lt_dladvise advise);
static int vm_close (lt_user_data loader_data, lt_module module);
static void * vm_sym (lt_user_data loader_data, lt_module module,
const char *symbolname);
+static lt_dlvtable *vtable = 0;
+
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
change between loaders. */
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
vtable->module_open = vm_open;
vtable->module_close = vm_close;
vtable->find_sym = vm_sym;
+ vtable->dlloader_exit = vl_exit;
vtable->dlloader_data = loader_data;
vtable->priority = LT_DLLOADER_PREPEND;
}
#define DL__SETERROR(errorcode) \
LT__SETERRORSTR (DLERROR (errorcode))
+
+/* A function called through the vtable when this loader is no
+ longer needed by the application. */
+static int
+vl_exit (lt_user_data LT__UNUSED loader_data)
+{
+ vtable = NULL;
+ return 0;
+}
+
+
/* A function called through the vtable to open a module with this
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
/* loader-dyld.c -- dynamic linking on darwin and OS X
Copyright (C) 1998, 1999, 2000, 2004, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Peter O'Gorman, 1998
NOTE: The canonical source of this file is maintained with the
static void * vm_sym (lt_user_data loader_data, lt_module module,
const char *symbolname);
+static lt_dlvtable *vtable = 0;
+
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
change between loaders. */
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = lt__zalloc (sizeof *vtable);
vtable->module_open = vm_open;
vtable->module_close = vm_close;
vtable->find_sym = vm_sym;
+ vtable->dlloader_exit = vl_exit;
vtable->dlloader_data = loader_data;
vtable->priority = LT_DLLOADER_APPEND;
}
static int dyld_cannot_close = 0;
+/* A function called through the vtable when this loader is no
+ longer needed by the application. */
+static int
+vl_exit (lt_user_data LT__UNUSED loader_data)
+{
+ vtable = NULL;
+ return 0;
+}
+
/* A function called through the vtable to initialise this loader. */
static int
vl_init (lt_user_data loader_data)
/* loader-load_add_on.c -- dynamic linking for BeOS
Copyright (C) 1998, 1999, 2000, 2004, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Thomas Tanner, 1998
NOTE: The canonical source of this file is maintained with the
/* Boilerplate code to set up the vtable for hooking this loader into
libltdl's loader list: */
+static int vl_exit (lt_user_data loader_data);
static lt_module vm_open (lt_user_data loader_data, const char *filename,
lt_dladvise advise);
static int vm_close (lt_user_data loader_data, lt_module module);
static void * vm_sym (lt_user_data loader_data, lt_module module,
const char *symbolname);
+static lt_dlvtable *vtable = 0;
+
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
change between loaders. */
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = lt__zalloc (sizeof *vtable);
vtable->module_open = vm_open;
vtable->module_close = vm_close;
vtable->find_sym = vm_sym;
+ vtable->dlloader_exit = vl_exit;
vtable->dlloader_data = loader_data;
vtable->priority = LT_DLLOADER_APPEND;
}
#include <kernel/image.h>
+/* A function called through the vtable when this loader is no
+ longer needed by the application. */
+static int
+vl_exit (lt_user_data LT__UNUSED loader_data)
+{
+ vtable = NULL;
+ return 0;
+}
+
/* A function called through the vtable to open a module with this
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
/* loader-loadlibrary.c -- dynamic linking for Win32
Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Thomas Tanner, 1998
NOTE: The canonical source of this file is maintained with the
/* Boilerplate code to set up the vtable for hooking this loader into
libltdl's loader list: */
+static int vl_exit (lt_user_data loader_data);
static lt_module vm_open (lt_user_data loader_data, const char *filename,
lt_dladvise advise);
static int vm_close (lt_user_data loader_data, lt_module module);
const char *symbolname);
static lt_dlinterface_id iface_id = 0;
+static lt_dlvtable *vtable = 0;
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
vtable->module_open = vm_open;
vtable->module_close = vm_close;
vtable->find_sym = vm_sym;
+ vtable->dlloader_exit = vl_exit;
vtable->dlloader_data = loader_data;
vtable->priority = LT_DLLOADER_APPEND;
}
#include <windows.h>
+/* A function called through the vtable when this loader is no
+ longer needed by the application. */
+static int
+vl_exit (lt_user_data LT__UNUSED loader_data)
+{
+ vtable = NULL;
+ return 0;
+}
+
/* A function called through the vtable to open a module with this
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
/* loader-preopen.c -- emulate dynamic linking using preloaded_symbols
Copyright (C) 1998, 1999, 2000, 2004, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Thomas Tanner, 1998
NOTE: The canonical source of this file is maintained with the
static void * vm_sym (lt_user_data loader_data, lt_module module,
const char *symbolname);
+static lt_dlvtable *vtable = 0;
+
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
change between loaders. */
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
static int
vl_exit (lt_user_data LT__UNUSED loader_data)
{
+ vtable = NULL;
free_symlists ();
return 0;
}
/* loader-shl_load.c -- dynamic linking with shl_load (HP-UX)
Copyright (C) 1998, 1999, 2000, 2004, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Thomas Tanner, 1998
NOTE: The canonical source of this file is maintained with the
/* Boilerplate code to set up the vtable for hooking this loader into
libltdl's loader list: */
+static int vl_exit (lt_user_data loader_data);
static lt_module vm_open (lt_user_data loader_data, const char *filename,
lt_dladvise advise);
static int vm_close (lt_user_data loader_data, lt_module module);
static void * vm_sym (lt_user_data loader_data, lt_module module,
const char *symbolname);
+static lt_dlvtable *vtable = 0;
+
/* Return the vtable for this loader, only the name and sym_prefix
attributes (plus the virtual function implementations, obviously)
change between loaders. */
lt_dlvtable *
get_vtable (lt_user_data loader_data)
{
- static lt_dlvtable *vtable = 0;
-
if (!vtable)
{
vtable = lt__zalloc (sizeof *vtable);
vtable->module_open = vm_open;
vtable->module_close = vm_close;
vtable->find_sym = vm_sym;
+ vtable->dlloader_exit = vl_exit;
vtable->dlloader_data = loader_data;
vtable->priority = LT_DLLOADER_APPEND;
}
#define LT_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | DYNAMIC_PATH)
+/* A function called through the vtable when this loader is no
+ longer needed by the application. */
+static int
+vl_exit (lt_user_data LT__UNUSED loader_data)
+{
+ vtable = NULL;
+ return 0;
+}
+
/* A function called through the vtable to open a module with this
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
# Test for
# http://lists.gnu.org/archive/html/bug-libtool/2007-01/msg00014.html
+# http://lists.gnu.org/archive/html/bug-libtool/2008-03/msg00013.html
AT_DATA([main.c],
[[#include <ltdl.h>
fprintf (stderr, "error during initialization: %s\n", lt_dlerror());
return 1;
}
+ if (lt_dlexit() != 0) {
+ fprintf (stderr, "error during first lt_dlexit: %s\n", lt_dlerror());
+ return 1;
+ }
+ if (lt_dlinit() != 0) {
+ fprintf (stderr, "error during second initialization: %s\n", lt_dlerror());
+ return 1;
+ }
if (!(b1 = xdlopen ("modb1.la"))) return 1;
if (xdlsymtest (b1, "fb1", "vb1")) return 1;
/* do not lt_dlclose here on purpose. */