This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix _dl_map_object


Hi!

The l->l_opencount == 0 test in _dl_map_object is not very good in the new
reference counting model, since ld.so will open/read/fstat/close the same
library multiple times if it is being added more than once during the same
dlopen call (or during dl_main), because l_opencount is bumped after all
dependencies are loaded (e.g. if a program has DT_NEEDED libc.so.6 and
libfoo.so.0 and libfoo.so.0 has DT_NEEDED libc.so.6, then libc.so.6 will be
open_verify'ed twice and caught by the later _dl_map_object_from_fd st_ino +
st_dev check).
Looking at October 18'th code (right before reference counting changes),
l_opencount was bumped immediately after _dl_new_object, with the single
exception when creating the fake entry if the library is not found.
So, IMHO either the test should go away completely (if we'll take fake
entries as sufficient) or replaced with l_faked test (if ld.so should try
again to find that library). I've attached both alternatives.

	Jakub
2001-02-06  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-load.c (_dl_map_object): Only skip matching name if it is a
	fake entry.

--- libc/elf/dl-load.c.jj	Mon Mar  5 16:19:11 2001
+++ libc/elf/dl-load.c	Tue Mar  6 12:27:42 2001
@@ -1512,11 +1512,8 @@ _dl_map_object (struct link_map *loader,
   for (l = _dl_loaded; l; l = l->l_next)
     {
       /* If the requested name matches the soname of a loaded object,
-	 use that object.  Elide this check for names that have not
-	 yet been opened.  */
-      /* XXX Is this test still correct after the reference counter
-	 handling rewrite?  */
-      if (l->l_opencount == 0)
+	 use that object.  Elide this check for faked names.  */
+      if (__builtin_expect (l->l_faked, 0))
 	continue;
       if (!_dl_name_match_p (name, l))
 	{
2001-02-06  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-load.c (_dl_map_object): Don't test l_opencount when
	looking for name matches.

--- libc/elf/dl-load.c.jj	Mon Mar  5 16:19:11 2001
+++ libc/elf/dl-load.c	Tue Mar  6 12:33:49 2001
@@ -1512,12 +1512,7 @@ _dl_map_object (struct link_map *loader,
   for (l = _dl_loaded; l; l = l->l_next)
     {
       /* If the requested name matches the soname of a loaded object,
-	 use that object.  Elide this check for names that have not
-	 yet been opened.  */
-      /* XXX Is this test still correct after the reference counter
-	 handling rewrite?  */
-      if (l->l_opencount == 0)
-	continue;
+	 use that object.  */
       if (!_dl_name_match_p (name, l))
 	{
 	  const char *soname;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]