This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #11941] Fix spurious assert in dlclose.

Hi, in following bug we did represent that destructor was called by reseting
l_init_called to zero. This triggered a assert in dlclose.

A solution would be add additional l_fini_called flag to represent this

	[BZ #11941]
	include/link.h (struct link_map): Add l_fini_called.
	elf/dl-fini.c (_dl_fini): Guard double call by l_fini_called
	instead of reseting l_init_called.

diff --git a/elf/dl-fini.c b/elf/dl-fini.c
index 458aaf1..6f72454 100644
--- a/elf/dl-fini.c
+++ b/elf/dl-fini.c
@@ -224,10 +224,10 @@ _dl_fini (void)
 	  l = maps[i];
-	  if (l->l_init_called)
+	  if (l->l_init_called && !l->l_fini_called)
 	      /* Make sure nothing happens if we are called twice.  */
-	      l->l_init_called = 0;
+	      l->l_fini_called = 1;
 	      /* Is there a destructor function?  */
 	      if (l->l_info[DT_FINI_ARRAY] != NULL
diff --git a/include/link.h b/include/link.h
index 1682467..17a9bed 100644
--- a/include/link.h
+++ b/include/link.h
@@ -169,6 +169,7 @@ struct link_map
       } l_type:2;
     unsigned int l_relocated:1;	/* Nonzero if object's relocations done.  */
     unsigned int l_init_called:1; /* Nonzero if DT_INIT function called.  */
+    unsigned int l_fini_called:1; /* Nonzero if DT_FINI function called.  */
     unsigned int l_global:1;	/* Nonzero if object in _dl_global_scope.  */
     unsigned int l_reserved:2;	/* Reserved for internal use.  */
     unsigned int l_phdr_allocated:1; /* Nonzero if the data structure pointed

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