From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32638 invoked by alias); 3 Feb 2020 02:12:18 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 32630 invoked by uid 89); 3 Feb 2020 02:12:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=suspect, simulator, nose, 5b6d1e4fa4fc682 X-HELO: mail-lj1-f193.google.com Received: from mail-lj1-f193.google.com (HELO mail-lj1-f193.google.com) (209.85.208.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Feb 2020 02:12:16 +0000 Received: by mail-lj1-f193.google.com with SMTP id r19so12909844ljg.3 for ; Sun, 02 Feb 2020 18:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d6Dtz8laboS7ahs9JpZynjC23FLpfaYDDkSbMvsICiM=; b=VU+Qkbu7M1YMAjUEjBLHrABrQHgyVN/XrJRYCh5UGQXA7rYuNZ8fUJ1V/8k/KkOgGm xpuDmy7S4WSaGCtiQSaOp07oOkSMFe5pOjKqILla1LDdafKw+gOhnl3f3LnjJiYuMcQ2 uPUkbRC95bXFvr0poDRY2eecYz5IbseBHzmZ3U51Ckr+evL14phLZ8+iqbVx3HQpXE+Z rofFYnRjoqViorviexJOogC1CC8v1bRJhrG406y3C0E5IKFqVL4RKjz4KBCjzY8l28/d JSfpL12oSuYSCp2G/FRwsofKzPCUZBbW74Ced78qwZXiHv1IoZvFRCcPtfoLOwJ/ZJs1 e0uw== MIME-Version: 1.0 References: <20200202214715.GA20838@embecosm.com> In-Reply-To: <20200202214715.GA20838@embecosm.com> From: William Tambe Date: Mon, 03 Feb 2020 02:12:00 -0000 Message-ID: Subject: Re: sim_engine_halt() broken in binutils 2.34 To: Andrew Burgess Cc: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2020-02/txt/msg00004.txt.bz2 On Sun, Feb 2, 2020 at 4:47 PM Andrew Burgess wrote: > > * William Tambe [2020-02-02 00:03:40 -0500]: > > > I am running GDB with target sim. > > > > Calling sim_engine_halt() triggers the following error: > > ../../binutils-gdb/gdb/inferior.c:286: internal-error: inferior* > > find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' > > failed. > > A problem internal to GDB has been detected, > > further debugging may prove unreliable. > > Quit this debugging session? (y or n) > > > > Any idea idea what changed ? > > I suspect that this is a similar issue (but not the exact same fix) as > something I already posted here: > > https://sourceware.org/ml/gdb-patches/2020-01/msg00980.html I tried using above fix, but it did not resolve the issue. > > You could double check if you like, I believe if you check out the > commit just before 5b6d1e4fa4fc682 then you'll find your issue goes > away. I could not quickly test above as I need to do rebase adjustments for the custom port that I am using. > > The problem is caused, I suspect, by a use of `inferior_ptid' at a > place where this used to not be the null_ptid, but now is null_ptid. > > I had a little nose around for places related to the simulator where > this bug might be hiding, but couldn't see anything obvious. > > If you could let us know which simulator you're using, and what you do > to trigger the call to sim_engine_halt then we might be able to > reproduce the issue. The simulator I am using is a custom port that is not upstream. sim_engine_halt() is used by simulators to do things like SIM_SIGTRAP, SIGABRT, SIGILL or SIM_SIGSEGV; The fact that sim_engine_halt() is broken makes gdb target sim useless because breakpoints cannot be set. > > You could also try to collect a backtrace from GDB at the point the > assertion triggers, I believe GDB offers to dump core on an assertion, > so you can use that to obtain the backtrace. We might get lucky, and > something in the backtrace could be the offender. See below backtrace from GDB when assert triggers due to sim_engine_halt() getting called for a breakpoint using SIM_SIGTRAP: ../../binutils-gdb/gdb/inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) (gdb) bt #0 0x00007ffff66c9bf9 in __GI___poll (fds=0x555555fd36e0, nfds=4, timeout=timeout@entry=-1) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x00005555556ecf90 in poll (__timeout=-1, __nfds=, __fds=) at /usr/include/x86_64-linux-gnu/bits/poll2.h:46 #2 gdb_wait_for_event (block=block@entry=1) at ../../binutils-gdb/gdb/event-loop.c:769 #3 0x00005555556ed152 in gdb_do_one_event () at ../../binutils-gdb/gdb/event-loop.c:346 #4 0x00005555556ed286 in gdb_do_one_event () at ../../binutils-gdb/gdb/event-loop.c:352 #5 0x000055555585d60f in gdb_readline_wrapper (prompt=) at ../../binutils-gdb/gdb/top.c:1078 #6 0x000055555588db16 in defaulted_query(const char *, char, typedef __va_list_tag __va_list_tag *) (ctlstr=, defchar=defchar@entry=0 '\000', args=args@entry=0x7fffffffd740) at ../../binutils-gdb/gdb/utils.c:867 #7 0x000055555588de5b in query (ctlstr=) at ../../binutils-gdb/gdb/utils.c:959 #8 0x000055555588e3a6 in internal_vproblem(internal_problem *, const char *, int, const char *, typedef __va_list_tag __va_list_tag *) ( problem=problem@entry=0x555555d59880 , file=, line=279, fmt=, ap=ap@entry=0x7fffffffd900) at ../../binutils-gdb/gdb/utils.c:372 #9 0x000055555588e4eb in internal_verror (file=, line=, fmt=, ap=ap@entry=0x7fffffffd900) at ../../binutils-gdb/gdb/utils.c:438 #10 0x00005555559590df in internal_error (file=file@entry=0x5555559f2cd0 "../../binutils-gdb/gdb/inferior.c", line=line@entry=279, fmt=) at ../../binutils-gdb/gdbsupport/errors.c:55 #11 0x000055555572e72f in find_inferior_pid (targ=, pid=) at ../../binutils-gdb/gdb/inferior.c:279 #12 0x0000555555856905 in find_thread_ptid (targ=targ@entry=0x555555d58f60 , ptid=...) at ../../binutils-gdb/gdb/thread.c:527 #13 0x000055555573f42d in handle_inferior_event (ecs=ecs@entry=0x7fffffffdd30) at ../../binutils-gdb/gdb/infrun.c:5062 #14 0x000055555574096f in fetch_inferior_event (client_data=) at ../../binutils-gdb/gdb/infrun.c:4002 #15 0x00005555556ed19c in check_async_event_handlers () at ../../binutils-gdb/gdb/event-loop.c:1062 #16 gdb_do_one_event () at ../../binutils-gdb/gdb/event-loop.c:325 #17 0x00005555556ed2be in gdb_do_one_event () at ../../binutils-gdb/gdb/event-loop.c:303 #18 start_event_loop () at ../../binutils-gdb/gdb/event-loop.c:370 #19 0x0000555555765018 in captured_command_loop () at ../../binutils-gdb/gdb/main.c:360 #20 0x0000555555766f75 in captured_main (data=) at ../../binutils-gdb/gdb/main.c:1203 #21 gdb_main (args=) at ../../binutils-gdb/gdb/main.c:1218 #22 0x00005555555bff1b in main (argc=, argv=) at ../../binutils-gdb/gdb/gdb.c:32 > > Best of luck! > > Andrew >