]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/loaders/dld_link.c (vl_exit): New function, zero out ...
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 4 Mar 2008 21:00:19 +0000 (21:00 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 4 Mar 2008 21:00:19 +0000 (21:00 +0000)
(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.

ChangeLog
NEWS
libltdl/loaders/dld_link.c
libltdl/loaders/dlopen.c
libltdl/loaders/dyld.c
libltdl/loaders/load_add_on.c
libltdl/loaders/loadlibrary.c
libltdl/loaders/preopen.c
libltdl/loaders/shl_load.c
tests/lt_dlexit.at

index ca8161bdd500165105fa492312c87c50fdf40bbe..19dd17eb39d36fd333bd861eaa59e449a8f72487 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+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
diff --git a/NEWS b/NEWS
index 7413ee2bd27aa839c830bd1449e4d1dfebc7e667..8d490f7f9a970de54c272b7b223daac5f08cf5dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,10 @@ NEWS - list of user-visible changes between releases of GNU Libtool
 
 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:
 
index 189ee3b09f63c0408bd04aacb6d9407b95a80418..7e882c9ece12e9235d1758707cf45e4f28e4057b 100644 (file)
@@ -1,7 +1,7 @@
 /* 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
@@ -45,20 +45,21 @@ LT_END_C_DECLS
 
 /* 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);
@@ -70,6 +71,7 @@ get_vtable (lt_user_data loader_data)
       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;
     }
@@ -92,6 +94,15 @@ get_vtable (lt_user_data loader_data)
 #  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.  */
index d8bc45b3ecab8b80998c40c02e42d2bd8d6667a2..94680c5a8abf63d677a79fcd9289b61b5b8076fa 100644 (file)
@@ -45,20 +45,21 @@ LT_END_C_DECLS
 
 /* 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);
@@ -73,6 +74,7 @@ get_vtable (lt_user_data loader_data)
       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;
     }
@@ -146,6 +148,17 @@ get_vtable (lt_user_data loader_data)
 #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.  */
index b6ee94365a741089622c8a370deb1c910d5aed77..b139d6c46f0b0c88d49c4e706dc2ac03308d81ca 100644 (file)
@@ -1,7 +1,7 @@
 /* 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
@@ -53,14 +53,14 @@ 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);
@@ -74,6 +74,7 @@ get_vtable (lt_user_data loader_data)
       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;
     }
@@ -181,6 +182,15 @@ static enum DYLD_BOOL (*lt__module_export) (NSModule module) = 0;
 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)
index f79604ff27056b190746a4ebef474d0bffde6fd3..379f9ba1d539423735196913d3131f6ca4c69331 100644 (file)
@@ -1,7 +1,7 @@
 /* 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
@@ -45,20 +45,21 @@ LT_END_C_DECLS
 
 /* 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);
@@ -70,6 +71,7 @@ get_vtable (lt_user_data loader_data)
       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;
     }
@@ -90,6 +92,15 @@ get_vtable (lt_user_data loader_data)
 
 #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.  */
index 71f90c718824d29267f49bd1dab58fa0d3bd7438..de5eee8146fa698b785bc967489f0c7a7f354f37 100644 (file)
@@ -1,7 +1,7 @@
 /* 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
@@ -49,6 +49,7 @@ LT_END_C_DECLS
 
 /* 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);
@@ -56,6 +57,7 @@ static void *  vm_sym   (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)
@@ -63,8 +65,6 @@ static lt_dlinterface_id iface_id = 0;
 lt_dlvtable *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_dlvtable *vtable = 0;
-
   if (!vtable)
     {
       vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
@@ -77,6 +77,7 @@ get_vtable (lt_user_data loader_data)
       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;
     }
@@ -97,6 +98,15 @@ get_vtable (lt_user_data loader_data)
 
 #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.  */
index 009ce4ea722a1bbca70e610ee1402ee6cefc7ec4..7149287d2037a94d4f719e4d32747bbc1867c2c0 100644 (file)
@@ -1,7 +1,7 @@
 /* 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
@@ -53,14 +53,14 @@ 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);
@@ -132,6 +132,7 @@ vl_init (lt_user_data LT__UNUSED loader_data)
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
+  vtable = NULL;
   free_symlists ();
   return 0;
 }
index 15f00bdfff26a759dfef09944c49137286100e39..5a09d87244f6e4d625f06ab3ce5466ae5af42e06 100644 (file)
@@ -1,7 +1,7 @@
 /* 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
@@ -45,20 +45,21 @@ LT_END_C_DECLS
 
 /* 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);
@@ -70,6 +71,7 @@ get_vtable (lt_user_data loader_data)
       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;
     }
@@ -133,6 +135,15 @@ get_vtable (lt_user_data loader_data)
 #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.  */
index 667ca79624ad925f20b386ddac01ae3e2bc5bf78..e9de5c6c00a0deb36ff31fc43b57b2bd498a6785 100644 (file)
@@ -32,6 +32,7 @@ AT_KEYWORDS([libltdl])
 
 # 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>
@@ -80,6 +81,14 @@ main (void)
     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.  */