This is the mail archive of the
mailing list for the GDB project.
[rfc] Fix removing breakpoint from shared library race
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 13 Aug 2008 22:34:14 +0200 (CEST)
- Subject: [rfc] Fix removing breakpoint from shared library race
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
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.
* 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;
b->inserted = (is == mark_inserted);
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE