Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] Fix removing breakpoint from shared library race
@ 2008-08-13 20:36 Ulrich Weigand
  2008-08-18 11:47 ` Joel Brobecker
  2008-08-26 17:43 ` Ulrich Weigand
  0 siblings, 2 replies; 6+ messages in thread
From: Ulrich Weigand @ 2008-08-13 20:36 UTC (permalink / raw)
  To: gdb-patches

Hello,

after a shared library was unloaded, we can no longer insert breakpoints
into its (no longer present) code segment.  Therefore, code in breakpoint.c
(disable_breakpoints_in_unloaded_shlib etc.) takes care to disable such
breakpoints.

However, in a multi-threaded application we cannot really guarantee that
we have noticed the shlib unload event at the time breakpoints are to be
inserted or removed.  For the insertion case, insert_bp_location therefore
has its own check, and handles unloaded shared libraries appropriately.

When *removing* breakpoints, however, there is no such check.  I have a
multi-threaded test case that reproducibly runs into an error when trying
to remove a breakpoint from a shared library that was *just* unloaded.

The patch below fixes this, by simply silently ignoring failures to remove
a breakpoint from a shared library code segment.  The breakpoint will be
cleanly disabled once disable_breakpoints_in_unloaded_shlib gets a chance
to run (or at the next attempt to insert it).

Am I missing some reason why we shouldn't get to this point?  Otherwise,
this seems a reasonble solution to me ...

Tested on powerpc-linux and powerpc64-linux.


Bye,
UIrich


ChangeLog:

	* breakpoint.c (remove_breakpoint): Do not fail if unable to remove
	breakpoint from shared library.


diff -urNp gdb-orig/gdb/breakpoint.c gdb-head/gdb/breakpoint.c
--- gdb-orig/gdb/breakpoint.c	2008-08-08 16:42:41.000000000 +0200
+++ gdb-head/gdb/breakpoint.c	2008-08-13 21:56:44.567419172 +0200
@@ -1642,6 +1642,13 @@ remove_breakpoint (struct bp_location *b
 	      val = 0;
 	    }
 	}
+
+      /* In some cases, we might not be able to remove a breakpoint
+	 in a shared library that has already been removed, but we
+	 have not yet processed the shlib unload event.  */
+      if (val && solib_address (b->address))
+	val = 0;
+
       if (val)
 	return val;
       b->inserted = (is == mark_inserted);
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-09-09 22:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-13 20:36 [rfc] Fix removing breakpoint from shared library race Ulrich Weigand
2008-08-18 11:47 ` Joel Brobecker
2008-08-18 14:15   ` Ulrich Weigand
2008-09-09 20:43     ` Joel Brobecker
2008-09-09 22:32       ` Ulrich Weigand
2008-08-26 17:43 ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox