From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eZKrAwuAKWqA1z8AWB0awg (envelope-from ) for ; Wed, 10 Jun 2026 11:17:31 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YKA80sGa; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E8FB71E0A3; Wed, 10 Jun 2026 11:17:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B61791E070 for ; Wed, 10 Jun 2026 11:17:29 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6958D4BA543C for ; Wed, 10 Jun 2026 15:17:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6958D4BA543C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YKA80sGa Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 181584BA5439 for ; Wed, 10 Jun 2026 15:17:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 181584BA5439 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 181584BA5439 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781104621; cv=none; b=F+UY9ny6AwIiO2V/E1c5mNvRBwB+RG8sld34i6jn2FUJII47AnO9yzN8i5e9FW5kaIZJd1/U4vxYBqHd9LXK/iguwtPpkPfZEiLWQNBAVNwd0ujRbPdFQaoL4c5EcpPbcURNlq8tJmlktn77YNo8eFV2kj711FsDj3omrpNp8ZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781104621; c=relaxed/simple; bh=z8UlbhBkxklici7ofn9be0YvVtaPdfjgpgZBB0pHjW0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qdfxCowKwnujC3WnEmd+Dqfo0E92KTgay2LqfOXnuLZLkivDzSMgi7DmL1KUp9NMotmPrYhKItX5KafROXrkDFEOiuCNw1qExPnrJZxSxHe3HYtEPF2NAQRgwsjFZRhUJpx75A+Vp+oJBWvibGibbB4az+Ook5y0lBM4KyY9HAg= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YKA80sGa DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 181584BA5439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781104620; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QBOceUre2efLZrSvgP5I0vgVnOGT5RxOZWj00NMNejY=; b=YKA80sGa35v2Oc9rdo2dRkZNU/LA627b78aAA0HsLMlASUA+q5PDhneLmX/qGMusQ3h9/f +zBl+UWhlYzVYZ97fBx4K5mHMoSstiLPCA+/IafKBEAv7s28fTph5i+aQbLDoqxYgWWEce ZHNJu7X62nnLaWFznbgk3+OBvZb3EyE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-fSFSGiupMbKPyZGpexZEBg-1; Wed, 10 Jun 2026 11:16:59 -0400 X-MC-Unique: fSFSGiupMbKPyZGpexZEBg-1 X-Mimecast-MFC-AGG-ID: fSFSGiupMbKPyZGpexZEBg_1781104618 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490bae3a39bso11580975e9.1 for ; Wed, 10 Jun 2026 08:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781104618; x=1781709418; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Whpk9nLa78u0mCwBwBSQZHlVqrXle6hmojE4iEJ6oeI=; b=MZwIZMLu367+3MCjXGg+96RoWaucUWicRs7DeOfs3px/SM8W6XIbU/j3k8+KcHKtcU XxZKxWAop7krv+Dhv4IspJtAWbrfmTP/R8H6uDWyeZEOQ1Zg/uGsyVxPc7w3JeAptXdn JtteOQDPFz3WV6QKLae18kYJrKg5FgjuVtXGRNDbIWuluNGINjExtVY3ITdyXsJah4ge UDXcLgXlfQimSHiSGUp+Liahbim+3mCzGJETPlif4/1MskYJK7hjXj2MhJE3Gdd9BPXx 1mam2EuuzSxdNhUsaafRK710dyR2sHTkbYlG4190sygbbmiBfFvKDNSjLwOoPaIDCWqK Smyg== X-Forwarded-Encrypted: i=1; AFNElJ/ONLX+30KwLGxA0Y7VSJCSTCCHZV1+sleJUNOPDj5vfmonD1PyYqV5CbgeWZnbXy8G9XOZR41HdAh7wQ==@sourceware.org X-Gm-Message-State: AOJu0Yz9HK6N52Q7zWm51D1ZHj1r42zfRvoa3822tHHNfAi63AEg60fj ZLCAQGRD42eFXvPlLX9NBahZhMahaA2akEwAM4urFwopJTFyWtK256AWhF91GCYgok7bE1Cf30L 53e96pxphcpFccfwiuQymHlX4IME1QL/57lb5y66HmFBVDzlQ+gzfmO4V24HpbuGDYcqjKDw= X-Gm-Gg: Acq92OEYYTCu6FCX+mwchWrd3nbG7Ws6vDxwujAOvEFPppLhDsi6Nq9gGr3px5+uz7N paTHa8AScgNKUvJ9VQCJ4ZXeDBYGpkN+zChAiCSwwvEyFJpAhiDLdkYvGVqFOGmG1Yu4FjmbxPx H1f6gSrA71UjnKWu3rMc4v6gdUfqmlb3FX5HQIgqaHn7W5UMEoIhJXSOCX0IFIl0QUHvBaMIjqq 38kEu9iIIsYWaVvRTJBDmsDRIYtx/dmS6uU6G5aaS7R65u4wzufF+INK0MI2i+VqctIDuSVgG7c IpdVT/turbsAI5N+DO2V5yM5sdJSBV1fU6ozgBVqc31tbdgaL2z+8Mgyn9QEtuIsEr/3qyz3x/x MjA622WJwkR07aNaMkd3F37Ub6IP/5o4drGuufqoRP7CuvbIHZ60= X-Received: by 2002:a05:600c:528c:b0:490:cdb2:fb5e with SMTP id 5b1f17b1804b1-490cdb2fd19mr243069005e9.22.1781104618158; Wed, 10 Jun 2026 08:16:58 -0700 (PDT) X-Received: by 2002:a05:600c:528c:b0:490:cdb2:fb5e with SMTP id 5b1f17b1804b1-490cdb2fd19mr243067995e9.22.1781104617393; Wed, 10 Jun 2026 08:16:57 -0700 (PDT) Received: from localhost (19.81.93.209.dyn.plus.net. [209.93.81.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc413adbsm576709295e9.15.2026.06.10.08.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 08:16:56 -0700 (PDT) From: Andrew Burgess To: =?utf-8?Q?S=C3=A9bastien?= Darche , gdb-patches@sourceware.org Cc: =?utf-8?Q?S=C3=A9bastien?= Darche Subject: Re: [PATCH v2] gdb/breakpoint: remove assertion when printing internal breakpoints without locspecs In-Reply-To: <20260610141509.12950-1-sdarche@efficios.com> References: <20260610141509.12950-1-sdarche@efficios.com> Date: Wed, 10 Jun 2026 16:16:56 +0100 Message-ID: <877bo6qvbr.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uggUKGSyyKtfYCTLlTS8Acr_BEvYhpYZ2lckjWCNwWI_1781104618 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Thanks, this looks great. I have one minor nit, no need to repost though..= . S=C3=A9bastien Darche writes: > When debugging gdb with `set debug breakpoint on`, gdb would crash if > the inferior happened to unload (through dlclose ()) a shared library > that contains jit debugging symbols: > > =09../../gdb/breakpoint.c:6473: internal-error: print_breakpoint_location= : > =09Assertion `b->locspec !=3D nullptr || (!user_breakpoint_p (b) && (b->t= ype > =09=3D=3D bp_shlib_event || b->type =3D=3D bp_thread_event))' failed. > =09A problem internal to GDB has been detected [...] > > This assertion was added in commit 5770f68 ("gdb: handle empty locspec > when printing breakpoints"). The assumption for this assert is that the > user may not call any (gdb-)debugging command between the time a shared > library is marked (bp_location->shlib_disabled is set) and the > breakpoint is actually removed. This would be true if the user called > `maint info breakpoints` as explained in the original commit message. > > However, if `set debug breakpoint on` is called, gdb prints debugging > info as the shared library is being unloaded. The ~jiter_objfile_data > dtor deletes the breakpoint, which calls remove_breakpoint_1 on the > bp_location in the recently unloaded shared object. Since `debug > breakpoint` is enabled, we go through print_breakpoint_location with the > bp_location's shlib_disabled flag set, which results in the assert > above. > > This commit removes the assertion as it is not true in all cases. I've > also included a minimal test case that loads a shared library with a > __jit_debug_register_code symbol. The test fails with the assert. > > Change-Id: Ia19c84f194a6f0c10315548c7f423bfd86ef0266 > --- > gdb/breakpoint.c | 17 ------- > gdb/testsuite/gdb.base/jit-unload-solib.c | 21 ++++++++ > gdb/testsuite/gdb.base/jit-unload.c | 45 ++++++++++++++++ > gdb/testsuite/gdb.base/jit-unload.exp | 62 +++++++++++++++++++++++ > 4 files changed, 128 insertions(+), 17 deletions(-) > create mode 100644 gdb/testsuite/gdb.base/jit-unload-solib.c > create mode 100644 gdb/testsuite/gdb.base/jit-unload.c > create mode 100644 gdb/testsuite/gdb.base/jit-unload.exp > > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 101dc57ee6b..85c4ffc3171 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -6457,23 +6457,6 @@ print_breakpoint_location (const breakpoint *b, co= nst bp_location *loc) > } > else > { > - /* Internal breakpoints don't have a locspec string, but can becom= e > -=09 pending if the shared library the breakpoint is in is unloaded. > -=09 For most internal breakpoint types though, after unloading the > -=09 shared library, the breakpoint will be deleted and never recreated > -=09 (see internal_breakpoint::re_set). But for two internal > -=09 breakpoint types bp_shlib_event and bp_thread_event this is not > -=09 true. Usually we don't expect the libraries that contain these > -=09 breakpoints to ever be unloaded, but a buggy inferior might do > -=09 such a thing, in which case GDB should be prepared to handle this > -=09 case. > - > -=09 If these two breakpoint types become pending then there will be no > -=09 locspec string. */ > - gdb_assert (b->locspec !=3D nullptr > -=09=09 || (!user_breakpoint_p (b) > -=09=09 && (b->type =3D=3D bp_shlib_event > -=09=09=09 || b->type =3D=3D bp_thread_event))); > const char *locspec_str > =09=3D (b->locspec !=3D nullptr ? b->locspec->to_string () : ""); > uiout->field_string ("pending", locspec_str); > diff --git a/gdb/testsuite/gdb.base/jit-unload-solib.c b/gdb/testsuite/gd= b.base/jit-unload-solib.c > new file mode 100644 > index 00000000000..3cf2c580320 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-unload-solib.c > @@ -0,0 +1,21 @@ > +/* This test program is part of GDB, the GNU debugger. > + > + Copyright 2026 Free Software Foundation, Inc. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see .= */ > + > +/* This simulates a JIT library. */ > + > + > +#include "jit-protocol.h" > diff --git a/gdb/testsuite/gdb.base/jit-unload.c b/gdb/testsuite/gdb.base= /jit-unload.c > new file mode 100644 > index 00000000000..92dfa16c055 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-unload.c > @@ -0,0 +1,45 @@ > +/* This test program is part of GDB, the GNU debugger. > + > + Copyright 2026 Free Software Foundation, Inc. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see .= */ > + > +/* Simulate loading of a library JIT code. */ > + > +#include > +#include > + > +#ifdef __WIN32__ > +#include > +#define dlopen(name, mode) LoadLibrary (TEXT (name)) > +#define dlclose(handle) FreeLibrary (handle) There's no definition of dlerror() here. Similar tests do: #define dlerror() "an error occurred" If you're happy to add that here then: Approved-By: Andrew Burgess Thanks, Andrew > +#else > +#include > +#endif > + > + > +int > +main (void) > +{ > + void *handle =3D dlopen (SHLIB_NAME, RTLD_NOW); > + > + if (handle =3D=3D NULL) > + { > + fprintf (stderr, "%s\n", dlerror ()); > + exit (1); > + } > + > + dlclose (handle); > + return 0; > +} > diff --git a/gdb/testsuite/gdb.base/jit-unload.exp b/gdb/testsuite/gdb.ba= se/jit-unload.exp > new file mode 100644 > index 00000000000..a5f9adbd76c > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-unload.exp > @@ -0,0 +1,62 @@ > +# Copyright 2026 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# This test checks that gdb does not assert when unloading a shared libr= ary > +# that defines a __jit_debug_register_code if `set debug breakpoint on` = is set. > + > +require allow_shlib_tests > + > +standard_testfile .c -solib.c > +set lib_testfile ${testfile}-lib > +set lib_binfile [standard_output_file $lib_testfile] > + > +if { [build_executable "build shlib" $lib_testfile $srcfile2 \ > +=09{debug shlib}] =3D=3D -1 } { > + return > +} > + > +set lib_testfile_on_target [gdb_download_shlib $lib_binfile] > + > +set options [list \ > +=09=09debug \ > +=09=09shlib_load \ > +=09=09additional_flags=3D-DSHLIB_NAME=3D\"${lib_testfile_on_target}\"] > + > +if { [prepare_for_testing "build main file" $testfile $srcfile \ > +=09$options] =3D=3D -1 } { > + return > +} > + > +if { ![runto_main] } { > + return > +} > + > +gdb_test_no_output "set debug breakpoint on" > + > +set saw_exit false > +gdb_test_multiple "continue" unload { > + -re "^\\\[Inferior $decimal \[^\r\n\]+ exited normally\\\]\r\n" { > +=09set saw_exit true > +=09exp_continue > + } > + > + -re "^$gdb_prompt $" { > +=09gdb_assert ${saw_exit} $gdb_test_name > + } > + > + -re "^\[^\r\n\]*\r\n" { > +=09exp_continue > + } > +} > --=20 > 2.54.0