This is the mail archive of the libc-alpha@sourceware.org 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]

ping: [patchv2] Fix vDSO l_name for GDB's: Can't read pathname for load map: Input/output error.


[patchv2] Fix vDSO l_name for GDB's: Can't read pathname for load map: Input/output error.
https://sourceware.org/ml/libc-alpha/2013-08/msg00364.html
Message-ID: <20130820133807.GA15877@host2.jankratochvil.net>
------------------------------------------------------------------------------
Hi,

this is a ping+update for:
	[patch] Fix vDSO l_name for GDB's: Can't read pathname for load map:Input/output error.
	http://sourceware.org/ml/libc-alpha/2009-10/msg00001.html
	Message-ID: <20091004161706.GA27450@host0.dyn.jankratochvil.net>

This is a long-term issue:
	http://sourceware.org/bugzilla/show_bug.cgi?id=8882 - GDB PR
	http://sourceware.org/bugzilla/show_bug.cgi?id=387 - libc PR -> INVALID
	http://sourceware.org/ml/gdb-patches/2009-10/msg00142.html GDB workaround #1
	http://sourceware.org/ml/gdb-patches/2013-08/msg00504.html GDB workaround #2

Solaris issue but completely unrelated to reasons for this libc/GDB patch:
	http://sourceware.org/ml/gdb-patches/2009-11/msg00454.html

It is workaroundable in GDB but still I believe it is most easy for consumers
to have readable link map in the first place.  Reading it several times
attempting to incrementally map newly found DSOs in each consumer is ugly.

The new patch tries to address the issue of former version if the string was
located in R/W page which was never been written to.

This condition gets applied for these callers:
elf/rtld.c:dl_main():1128:
      /* Create a link_map for the executable itself.
         This will be what dlopen on "" returns.  */
      main_map = _dl_new_object ((char *) "", "", lt_executable, NULL,
                                 __RTLD_OPENEXEC, LM_ID_BASE);
elf/setup-vdso.h:setup_vdso():32:
  struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL,
                                       0, LM_ID_BASE);


Thanks,
Jan


libc/
2013-08-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix reading link map from a core file by debugger.
	* elf/dl-object.c (_dl_new_object): Initialize L_NAME from NEWNAME if
	it is empty.

diff --git a/elf/dl-object.c b/elf/dl-object.c
index 0f594d2..e432c46 100644
--- a/elf/dl-object.c
+++ b/elf/dl-object.c
@@ -88,7 +88,9 @@ _dl_new_object (char *realname, const char *libname, int type,
   /* newname->next = NULL;	We use calloc therefore not necessary.  */
   newname->dont_free = 1;
 
-  new->l_name = realname;
+  /* Ensure empty strings from readonly memory are stored in a written page so
+     the string gets dumped into the core file.  */
+  new->l_name = *realname ? realname : newname->name + libname_len - 1;
   new->l_type = type;
   /* If we set the bit now since we know it is never used we avoid
      dirtying the cache line later.  */


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