This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Fix crash when setting solib-search-path


Presently, if we connect to a remote target and then do:

	set solib-search-path <whatever>

and then immediately do anything that requires showing
backtrace, or current frame, GDB is prone to do two things:

1. Crash, with diagnostic such as:
internal-error: dwarf2_frame_cache: Assertion `fde != NULL' failed.

2. Not crash, but totally forget about ld.so, and therefore
claim we are in unknown function in unknown file.

Both issues happen because we reload all shared libraries. This
leaves dangling pointers from frames (or specifically, from
dwarf unwinder data attached to frames). Also, when we've
just attached, we don't have real list of shared libraries.
Normally, the svr4_default_sos function can help and report
the dynamic linker. However, reload_shared_libraries
eventually calls svr4_clear_solib, which clears debug_loader_offset_p,
and after that svr4_default_sos is of no help.

This patch fixes the problems. Tested on powerpc and x86 without
any breakage. OK?

- Volodya
Index: gdb/solib.c
===================================================================
--- gdb/solib.c	(revision 194706)
+++ gdb/solib.c	(revision 194707)
@@ -974,6 +974,28 @@
 {
   no_shared_libraries (NULL, from_tty);
   solib_add (NULL, from_tty, NULL, auto_solib_add);
+  /* Creating inferior hooks here has two purposes. First, if we reload 
+     shared libraries then the address of solib breakpoint we've computed
+     previously might be no longer valid.  For example, if we forgot to set
+     solib-absolute-prefix and are setting it right now, then the previous
+     breakpoint address is plain wrong.  Second, installing solib hooks
+     also implicitly figures were ld.so is and loads symbols for it.
+     Absent this call, if we've just connected to a target and set 
+     solib-absolute-prefix or solib-search-path, we'll lose all information
+     about ld.so.  */
+  if (target_has_execution)
+    {
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
+      SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+#else
+      solib_create_inferior_hook ();
+#endif
+    }
+  /* We have unloaded and then reloaded debug info for all shared libraries.
+     However, frames may still reference them, for example a frame's 
+     unwinder might still point of DWARF FDE structures that are now freed.
+     Reinit frame cache to avoid crashing.  */
+  reinit_frame_cache ();
 }
 
 static void
Index: ChangeLog.csl
===================================================================
--- ChangeLog.csl	(revision 194706)
+++ ChangeLog.csl	(revision 194707)
@@ -1,3 +1,13 @@
+2008-02-27  Vladimir Prus  <vladimir@codesourcery.com>
+
+	Issue #2465
+	* release-notes-csl.xm: Describe change.
+
+	gdb/
+	* solib.c (reload_shared_libraries): Give
+	inferior a chance to reset solib breakpoint.
+	Reinit frame cache.
+	
 2008-02-15  Mark Mitchell  <mark@codesourcery.com>
 
 	* release-notes-csl.xml: Tweak release note for Issue #2545.

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