From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15797 invoked by alias); 13 Aug 2008 20:36:07 -0000 Received: (qmail 15757 invoked by uid 22791); 13 Aug 2008 20:36:00 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.29.156) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 13 Aug 2008 20:35:01 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7DKYET6565178 for ; Wed, 13 Aug 2008 20:34:14 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7DKYExe4161554 for ; Wed, 13 Aug 2008 22:34:14 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7DKYEQH005263 for ; Wed, 13 Aug 2008 22:34:14 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id m7DKYEEK005260 for ; Wed, 13 Aug 2008 22:34:14 +0200 Message-Id: <200808132034.m7DKYEEK005260@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Wed, 13 Aug 2008 22:34:14 +0200 Subject: [rfc] Fix removing breakpoint from shared library race To: gdb-patches@sourceware.org Date: Wed, 13 Aug 2008 20:36:00 -0000 From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00361.txt.bz2 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