public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "blarsen at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug record/30025] New: Adding an inferior when already recording corrupts the first inferior state
Date: Thu, 19 Jan 2023 11:32:41 +0000	[thread overview]
Message-ID: <bug-30025-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=30025

            Bug ID: 30025
           Summary: Adding an inferior when already recording corrupts the
                    first inferior state
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: record
          Assignee: unassigned at sourceware dot org
          Reporter: blarsen at redhat dot com
  Target Milestone: ---

Created attachment 14607
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14607&action=edit
Minimal reproducer

When debugging an inferior whose execution is being recorded and a new inferior
is added, the original inferior's state seems to be corrupted somehow. As an
example, debugging the program attached to this bug I got the following
session:

$ ./gdb -q ~/a.out
Reading symbols from /home/blarsen/a.out...
(gdb) start
Temporary breakpoint 1 at 0x401137: file t.c, line 7.
Starting program: /home/blarsen/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at t.c:7
7           int q = 0;
(gdb) record
(gdb) n
8           fact(5);
(gdb) add-inferior -exec ~/a.out
[New inferior 2]
Added inferior 2 on connection 1 (native)
Reading symbols from /home/blarsen/a.out...
(gdb) inferior 2
[Switching to inferior 2 [<null>] (/home/blarsen/a.out)]
(gdb) start
Temporary breakpoint 2 at 0x401137: -qualified main. (2 locations)
Starting program: /home/blarsen/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Thread 2.1 "a.out" hit Temporary breakpoint 2.2, main () at t.c:7
7           int q = 0;
(gdb) inferior 1
[Switching to inferior 1 [process 106244] (/home/blarsen/a.out)]
[Switching to thread 1.1 (Thread 0x7ffff7fa6600 (LWP 106244))]
#0  main () at t.c:8
8           fact(5);
(gdb) n

Thread 1.1 "a.out" received signal SIGTRAP, Trace/breakpoint trap.
0x0000000000401115 in fact (n=1) at t.c:2
2           if (n<2) return n;


When the SIGTRAP happens isn't consistent, and sometimes it happens in a way
that seems to corrupt the parameter, I've seen values ranging from 32 thousand
to -17 thousand.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-01-19 11:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 11:32 blarsen at redhat dot com [this message]
2023-01-19 15:34 ` [Bug record/30025] Adding an inferior when already recording makes GDB not handle SIGTRAP correctly blarsen at redhat dot com
2023-01-19 15:42 ` blarsen at redhat dot com
2023-01-25 17:07 ` blarsen at redhat dot com
2024-04-03 20:10 ` blarsen at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30025-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).