public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
@ 2021-07-14  7:12 vries at gcc dot gnu.org
  2021-07-14  7:12 ` [Bug record/28086] " vries at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14  7:12 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 28086
           Summary: inferior.c:303: internal-error: inferior*
                    find_inferior _pid(process_stratum_target*, int):
                    Assertion `pid != 0' failed.
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: record
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

When running test-case gdb.btrace/enable-new-thread.exp on openSUSE tumbleweed,
I run into:
...
FAIL: gdb.btrace/enable-new-thread.exp: continue to breakpoint: cont to bp.1
(GDB internal error)
...

In more detail:
...
(gdb) record btrace^M
(gdb) PASS: gdb.btrace/enable-new-thread.exp: record btrace
break 24^M
Breakpoint 2 at 0x40113e: file
/data/gdb_versions/devel/src/gdb/testsuite/gdb.btrace/enable-new-thread.c, line
24.^M
(gdb) continue^M
Continuing.^M
/data/gdb_versions/devel/src/gdb/inferior.c:303: internal-error: inferior*
find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
...

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
@ 2021-07-14  7:12 ` vries at gcc dot gnu.org
  2021-07-14  7:14 ` vries at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14  7:12 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |markus.t.metzger at intel dot com

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
  2021-07-14  7:12 ` [Bug record/28086] " vries at gcc dot gnu.org
@ 2021-07-14  7:14 ` vries at gcc dot gnu.org
  2021-07-14  7:19 ` vries at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14  7:14 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Backtrace:
...
Thread 1 "gdb" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49        return ret;
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff72d8864 in __GI_abort () at abort.c:79
#2  0x0000000000b2add9 in dump_core () at
/data/gdb_versions/devel/src/gdb/utils.c:204
#3  0x0000000000b2b2ea in internal_vproblem(internal_problem *, const char *,
int, const char *, typedef __va_list_tag __va_list_tag *) (
    problem=0x15179c0 <internal_error_problem>, 
    file=0xee5fb0 "/data/gdb_versions/devel/src/gdb/inferior.c", line=303, 
    fmt=0xee5d4b "%s: Assertion `%s' failed.", ap=0x7fffffffadc8)
    at /data/gdb_versions/devel/src/gdb/utils.c:414
#4  0x0000000000b2b3ae in internal_verror (
    file=0xee5fb0 "/data/gdb_versions/devel/src/gdb/inferior.c", line=303, 
    fmt=0xee5d4b "%s: Assertion `%s' failed.", ap=0x7fffffffadc8)
    at /data/gdb_versions/devel/src/gdb/utils.c:439
#5  0x0000000000dd5828 in internal_error (
    file=0xee5fb0 "/data/gdb_versions/devel/src/gdb/inferior.c", line=303, 
    fmt=0xee5d4b "%s: Assertion `%s' failed.")
    at /data/gdb_versions/devel/src/gdbsupport/errors.cc:55
#6  0x00000000007922fa in find_inferior_pid (
    targ=0x1522ac0 <the_amd64_linux_nat_target>, pid=0)
    at /data/gdb_versions/devel/src/gdb/inferior.c:303
#7  0x00000000007923b0 in find_inferior_ptid (
    targ=0x1522ac0 <the_amd64_linux_nat_target>, ptid=...)
    at /data/gdb_versions/devel/src/gdb/inferior.c:317
#8  0x0000000000a9b8b4 in find_thread_ptid (
    targ=0x1522ac0 <the_amd64_linux_nat_target>, ptid=...)
    at /data/gdb_versions/devel/src/gdb/thread.c:487
#9  0x0000000000a9a3b8 in
all_matching_threads_iterator::all_matching_threads_iterator (
    this=0x7fffffffb098, filter_target=0x1522ac0 <the_amd64_linux_nat_target>, 
    filter_ptid=...) at /data/gdb_versions/devel/src/gdb/thread-iter.c:125
#10 0x0000000000525308 in filtered_iterator<all_matching_threads_iterator,
non_exited_thread_filter>::filtered_iterator<process_stratum_target* const&,
ptid_t const&> (
    this=0x7fffffffb090)
    at /data/gdb_versions/devel/src/gdb/../gdbsupport/filtered-iterator.h:42
#11 0x0000000000523d13 in all_non_exited_threads_range::begin
(this=0x7fffffffb070)
    at /data/gdb_versions/devel/src/gdb/thread-iter.h:243
#12 0x0000000000928c53 in record_btrace_target::record_is_replaying (
    this=0x1516a30 <record_btrace_ops>, ptid=...)
    at /data/gdb_versions/devel/src/gdb/record-btrace.c:1411
#13 0x0000000000928d66 in record_btrace_target::xfer_partial (
    this=0x1516a30 <record_btrace_ops>, object=TARGET_OBJECT_MEMORY, annex=0x0, 
    readbuf=0x7fffffffb5c8 "\240\232\334\001", writebuf=0x0,
offset=140737351496357, 
    len=1, xfered_len=0x7fffffffb4c8)
    at /data/gdb_versions/devel/src/gdb/record-btrace.c:1437
#14 0x0000000000a7f9ab in raw_memory_xfer_partial (ops=0x1516a30
<record_btrace_ops>, 
    readbuf=0x7fffffffb5c8 "\240\232\334\001", writebuf=0x0,
memaddr=140737351496357, 
    len=1, xfered_len=0x7fffffffb4c8) at
/data/gdb_versions/devel/src/gdb/target.c:1504
#15 0x0000000000a7fdbe in memory_xfer_partial_1 (ops=0x1516a30
<record_btrace_ops>, 
    object=TARGET_OBJECT_CODE_MEMORY, readbuf=0x7fffffffb5c8
"\240\232\334\001", 
    writebuf=0x0, memaddr=140737351496357, len=1, xfered_len=0x7fffffffb4c8)
    at /data/gdb_versions/devel/src/gdb/target.c:1635
#16 0x0000000000a7fe48 in memory_xfer_partial (ops=0x1516a30
<record_btrace_ops>, 
    object=TARGET_OBJECT_CODE_MEMORY, readbuf=0x7fffffffb5c8
"\240\232\334\001", 
    writebuf=0x0, memaddr=140737351496357, len=1, xfered_len=0x7fffffffb4c8)
    at /data/gdb_versions/devel/src/gdb/target.c:1664
#17 0x0000000000a800c6 in target_xfer_partial (ops=0x1516a30
<record_btrace_ops>, 
    object=TARGET_OBJECT_CODE_MEMORY, annex=0x0, 
    readbuf=0x7fffffffb5c8 "\240\232\334\001", writebuf=0x0,
offset=140737351496357, 
    len=1, xfered_len=0x7fffffffb4c8) at
/data/gdb_versions/devel/src/gdb/target.c:1721
#18 0x0000000000a808de in target_read_partial (ops=0x1516a30
<record_btrace_ops>, 
    object=TARGET_OBJECT_CODE_MEMORY, annex=0x0, buf=0x7fffffffb5c8
"\240\232\334\001", 
    offset=140737351496357, len=1, xfered_len=0x7fffffffb4c8)
    at /data/gdb_versions/devel/src/gdb/target.c:1974
#19 0x0000000000a809de in target_read (ops=0x1516a30 <record_btrace_ops>, 
    object=TARGET_OBJECT_CODE_MEMORY, annex=0x0, buf=0x7fffffffb5c8
"\240\232\334\001", 
    offset=140737351496357, len=1) at
/data/gdb_versions/devel/src/gdb/target.c:2014
#20 0x0000000000a8058a in target_read_code (memaddr=140737351496357, 
    myaddr=0x7fffffffb5c8 "\240\232\334\001", len=1)
    at /data/gdb_versions/devel/src/gdb/target.c:1869
#21 0x0000000000615fb7 in gdb_disassembler::dis_asm_read_memory (
    memaddr=140737351496357, myaddr=0x7fffffffb5c8 "\240\232\334\001", len=1, 
    info=0x7fffffffb878) at /data/gdb_versions/devel/src/gdb/disasm.c:139
#22 0x0000000000b70b11 in fetch_data (info=0x7fffffffb878, 
    addr=0x7fffffffb5c9 "\232\334\001")
    at /data/gdb_versions/devel/src/opcodes/i386-dis.c:194
#23 0x0000000000b70c77 in ckprefix ()
    at /data/gdb_versions/devel/src/opcodes/i386-dis.c:8628
#24 0x0000000000b72e1a in print_insn (pc=140737351496357, info=0x7fffffffb878)
    at /data/gdb_versions/devel/src/opcodes/i386-dis.c:9587
#25 0x0000000000b7125b in print_insn_i386 (pc=140737351496357,
info=0x7fffffffb878)
    at /data/gdb_versions/devel/src/opcodes/i386-dis.c:8894
#26 0x000000000049e75c in default_print_insn (memaddr=140737351496357, 
    info=0x7fffffffb878) at /data/gdb_versions/devel/src/gdb/arch-utils.c:1029
#27 0x000000000076a9b7 in i386_print_insn (pc=140737351496357,
info=0x7fffffffb878)
    at /data/gdb_versions/devel/src/gdb/i386-tdep.c:4013
#28 0x00000000007198e9 in gdbarch_print_insn (gdbarch=0x19c4540,
vma=140737351496357, 
    info=0x7fffffffb878) at /data/gdb_versions/devel/src/gdb/gdbarch.c:3478
#29 0x0000000000617f6d in gdb_disassembler::print_insn (this=0x7fffffffb870, 
    memaddr=140737351496357, branch_delay_insns=0x0)
    at /data/gdb_versions/devel/src/gdb/disasm.c:795
#30 0x00000000006181b6 in gdb_print_insn (gdbarch=0x19c4540,
memaddr=140737351496357, 
    stream=0x153d038 <null_stream>, branch_delay_insns=0x0)
    at /data/gdb_versions/devel/src/gdb/disasm.c:850
#31 0x0000000000618219 in gdb_insn_length (gdbarch=0x19c4540,
addr=140737351496357)
    at /data/gdb_versions/devel/src/gdb/disasm.c:859
#32 0x000000000053bcff in btrace_compute_ftrace_bts (tp=0x1878dc0, 
    btrace=0x7fffffffbb38, gaps=...) at
/data/gdb_versions/devel/src/gdb/btrace.c:1107
#33 0x000000000053bedc in btrace_compute_ftrace_1 (tp=0x1878dc0,
btrace=0x7fffffffbb30, 
    cpu=0x0, gaps=...) at /data/gdb_versions/devel/src/gdb/btrace.c:1527
#34 0x000000000053bfc9 in btrace_compute_ftrace (tp=0x1878dc0,
btrace=0x7fffffffbb30, 
    cpu=0x0) at /data/gdb_versions/devel/src/gdb/btrace.c:1560
#35 0x000000000053c0cb in btrace_add_pc (tp=0x1878dc0)
    at /data/gdb_versions/devel/src/gdb/btrace.c:1589
#36 0x000000000053c315 in btrace_enable (tp=0x1878dc0, 
    conf=0x1539b50 <record_btrace_conf>)
    at /data/gdb_versions/devel/src/gdb/btrace.c:1629
#37 0x00000000009264e8 in record_btrace_enable_warn (tp=0x1878dc0)
    at /data/gdb_versions/devel/src/gdb/record-btrace.c:294
#38 0x000000000083cb86 in std::__invoke_impl<void, void (*&)(thread_info*),
thread_info*> (__f=@0x229e4d8: 0x9264a7
<record_btrace_enable_warn(thread_info*)>)
    at /usr/include/c++/11/bits/invoke.h:61
#39 0x000000000083b7b3 in std::__invoke_r<void, void (*&)(thread_info*),
thread_info*> (
    __fn=@0x229e4d8: 0x9264a7 <record_btrace_enable_warn(thread_info*)>)
    at /usr/include/c++/11/bits/invoke.h:111
#40 0x000000000083af3e in std::_Function_handler<void (thread_info*), void
(*)(thread_info*)>::_M_invoke(std::_Any_data const&, thread_info*&&)
(__functor=..., 
    __args#0=@0x7fffffffbcf0: 0x1878dc0) at
/usr/include/c++/11/bits/std_function.h:291
#41 0x0000000000aa22bd in std::function<void
(thread_info*)>::operator()(thread_info*) const (this=0x229e4d8,
__args#0=0x1878dc0) at /usr/include/c++/11/bits/std_function.h:560
#42 0x0000000000aa1160 in gdb::observers::observable<thread_info*>::notify (
    this=0x1538c20 <gdb::observers::new_thread>, args#0=0x1878dc0)
    at /data/gdb_versions/devel/src/gdb/../gdbsupport/observable.h:150
#43 0x0000000000a9ad03 in add_thread_silent (
    targ=0x1522ac0 <the_amd64_linux_nat_target>, ptid=...)
    at /data/gdb_versions/devel/src/gdb/thread.c:263
#44 0x0000000000a9ad33 in add_thread_with_info (
    targ=0x1522ac0 <the_amd64_linux_nat_target>, ptid=..., priv=0x22c4940)
    at /data/gdb_versions/devel/src/gdb/thread.c:272
#45 0x00000000007f65a5 in record_thread (info=0x1db95a0, tp=0x0, ptid=..., 
    th_p=0x7fffffffc0e0, ti_p=0x7fffffffbf60)
    at /data/gdb_versions/devel/src/gdb/linux-thread-db.c:1380
#46 0x00000000007f444b in thread_from_lwp (stopped=0x18991c0, ptid=...)
    at /data/gdb_versions/devel/src/gdb/linux-thread-db.c:429
#47 0x00000000007f44ce in thread_db_notice_clone (parent=..., child=...)
    at /data/gdb_versions/devel/src/gdb/linux-thread-db.c:447
#48 0x00000000007dde8d in linux_handle_extended_wait (lp=0x199d6c0,
status=4991)
    at /data/gdb_versions/devel/src/gdb/linux-nat.c:1981
#49 0x00000000007e024e in linux_nat_filter_event (lwpid=23200, status=198015)
    at /data/gdb_versions/devel/src/gdb/linux-nat.c:2920
#50 0x00000000007e0f40 in linux_nat_wait_1 (ptid=..., ourstatus=0x7fffffffcfb8, 
    target_options=...) at /data/gdb_versions/devel/src/gdb/linux-nat.c:3202
#51 0x00000000007e1b12 in linux_nat_target::wait (
    this=0x1522ac0 <the_amd64_linux_nat_target>, ptid=...,
ourstatus=0x7fffffffcfb8, 
    target_options=...) at /data/gdb_versions/devel/src/gdb/linux-nat.c:3440
#52 0x00000000007f66b7 in thread_db_target::wait (
    this=0x150a680 <the_thread_db_target>, ptid=..., ourstatus=0x7fffffffcfb8, 
    options=...) at /data/gdb_versions/devel/src/gdb/linux-thread-db.c:1412
#53 0x000000000092b0c2 in record_btrace_target::wait (
    this=0x1516a30 <record_btrace_ops>, ptid=..., status=0x7fffffffcfb8,
options=...)
    at /data/gdb_versions/devel/src/gdb/record-btrace.c:2547
#54 0x0000000000a81a6f in target_wait (ptid=..., status=0x7fffffffcfb8,
options=...)
    at /data/gdb_versions/devel/src/gdb/target.c:2608
#55 0x000000000079eb29 in do_target_wait_1 (inf=0x15c44a0, ptid=..., 
    status=0x7fffffffcfb8, options=...)
    at /data/gdb_versions/devel/src/gdb/infrun.c:3640
#56 0x000000000079ecb3 in operator() (__closure=0x7fffffffcdf0, inf=0x15c44a0)
    at /data/gdb_versions/devel/src/gdb/infrun.c:3701
#57 0x000000000079efb5 in do_target_wait (ecs=0x7fffffffcf90, options=...)
    at /data/gdb_versions/devel/src/gdb/infrun.c:3720
#58 0x000000000079fc89 in fetch_inferior_event ()
    at /data/gdb_versions/devel/src/gdb/infrun.c:4069
#59 0x000000000078307d in inferior_event_handler (event_type=INF_REG_EVENT)
    at /data/gdb_versions/devel/src/gdb/inf-loop.c:41
#60 0x00000000007e32e9 in handle_target_event (error=0, client_data=0x0)
    at /data/gdb_versions/devel/src/gdb/linux-nat.c:4227
#61 0x0000000000dd649c in handle_file_event (file_ptr=0x22aa180, ready_mask=1)
    at /data/gdb_versions/devel/src/gdbsupport/event-loop.cc:575
#62 0x0000000000dd6a3b in gdb_wait_for_event (block=0)
    at /data/gdb_versions/devel/src/gdbsupport/event-loop.cc:701
#63 0x0000000000dd595e in gdb_do_one_event ()
    at /data/gdb_versions/devel/src/gdbsupport/event-loop.cc:212
#64 0x0000000000aa6046 in wait_sync_command_done ()
    at /data/gdb_versions/devel/src/gdb/top.c:528
#65 0x0000000000aa60cf in maybe_wait_sync_command_done (was_sync=0)
    at /data/gdb_versions/devel/src/gdb/top.c:545
#66 0x0000000000aa66c3 in execute_command (p=0x18b3ec8 "", from_tty=0)
    at /data/gdb_versions/devel/src/gdb/top.c:676
#67 0x00000000006db5ba in command_handler (command=0x18b3ec0 "continue")
    at /data/gdb_versions/devel/src/gdb/event-top.c:588
#68 0x0000000000aa5ebe in read_command_file (stream=0x1895a20)
    at /data/gdb_versions/devel/src/gdb/top.c:443
#69 0x00000000005a1c43 in script_from_file (stream=0x1895a20, 
    file=0x7fffffffe160 "outputs/gdb.btrace/enable-new-thread/gdb.in.1")
    at /data/gdb_versions/devel/src/gdb/cli/cli-script.c:1642
#70 0x0000000000582a38 in source_script_from_stream (stream=0x1895a20, 
    file=0x7fffffffe160 "outputs/gdb.btrace/enable-new-thread/gdb.in.1", 
    file_to_open=0x183fa80 "outputs/gdb.btrace/enable-new-thread/gdb.in.1")
    at /data/gdb_versions/devel/src/gdb/cli/cli-cmds.c:705
#71 0x0000000000582b5f in source_script_with_search (
    file=0x7fffffffe160 "outputs/gdb.btrace/enable-new-thread/gdb.in.1",
from_tty=0, 
    search_path=0) at /data/gdb_versions/devel/src/gdb/cli/cli-cmds.c:750
#72 0x0000000000582bd7 in source_script (
    file=0x7fffffffe160 "outputs/gdb.btrace/enable-new-thread/gdb.in.1",
from_tty=0)
    at /data/gdb_versions/devel/src/gdb/cli/cli-cmds.c:759
#73 0x000000000080e3b9 in catch_command_errors (
    command=0x582bb2 <source_script(char const*, int)>, 
    arg=0x7fffffffe160 "outputs/gdb.btrace/enable-new-thread/gdb.in.1",
from_tty=0, 
    do_bp_actions=false) at /data/gdb_versions/devel/src/gdb/main.c:523
#74 0x000000000080e53d in execute_cmdargs (cmdarg_vec=0x7fffffffd8c0, 
    file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x7fffffffd89c)
    at /data/gdb_versions/devel/src/gdb/main.c:615
#75 0x000000000080f921 in captured_main_1 (context=0x7fffffffdad0)
    at /data/gdb_versions/devel/src/gdb/main.c:1322
#76 0x000000000080fb1f in captured_main (data=0x7fffffffdad0)
    at /data/gdb_versions/devel/src/gdb/main.c:1343
#77 0x000000000080fb8a in gdb_main (args=0x7fffffffdad0)
    at /data/gdb_versions/devel/src/gdb/main.c:1368
#78 0x00000000004188cd in main (argc=10, argv=0x7fffffffdbe8)
    at /data/gdb_versions/devel/src/gdb/gdb.c:32
...

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
  2021-07-14  7:12 ` [Bug record/28086] " vries at gcc dot gnu.org
  2021-07-14  7:14 ` vries at gcc dot gnu.org
@ 2021-07-14  7:19 ` vries at gcc dot gnu.org
  2021-07-14  9:33 ` vries at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14  7:19 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
AFAICT, the problem originates here:
...
(gdb) up
#13 0x0000000000928d66 in record_btrace_target::xfer_partial (
    this=0x1516a30 <record_btrace_ops>, object=TARGET_OBJECT_MEMORY, annex=0x0, 
    readbuf=0x7fffffffb5c8 "\240\232\334\001", writebuf=0x0,
offset=140737351496357, 
    len=1, xfered_len=0x7fffffffb4c8)
    at /data/gdb_versions/devel/src/gdb/record-btrace.c:1437
1437          && record_is_replaying (inferior_ptid))
(gdb)
...
because:
...
(gdb) p inferior_ptid
$14 = {m_pid = 0, m_lwp = 0, m_tid = 0}
...
after which we end up here:
...
(gdb) down
#6  0x00000000007922fa in find_inferior_pid (
    targ=0x1522ac0 <the_amd64_linux_nat_target>, pid=0)
    at /data/gdb_versions/devel/src/gdb/inferior.c:303
303       gdb_assert (pid != 0);
...

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-14  7:19 ` vries at gcc dot gnu.org
@ 2021-07-14  9:33 ` vries at gcc dot gnu.org
  2021-07-14 14:41 ` simark at simark dot ca
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14  9:33 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Bisects to:
...
0618ae41497998792701b72f34ea4859cf95aafc is the first bad commit
commit 0618ae41497998792701b72f34ea4859cf95aafc
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Jun 18 14:05:28 2021 -0400

    gdb: optimize all_matching_threads_iterator
...

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-14  9:33 ` vries at gcc dot gnu.org
@ 2021-07-14 14:41 ` simark at simark dot ca
  2021-07-14 15:13 ` vries at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: simark at simark dot ca @ 2021-07-14 14:41 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
I didn't manage to reproduce:

  # of expected passes            7

At frame 42, we have the new_thread observable being fired, because a new
thread is being added.  When the new_thread observable, I don't think there is
any guarantee about the global context, value of inferior_ptid and all.

btrace_compute_ftrace_bts at frame 32 is the last frame where we know the
thread we are working on.  It then calls gdb_insn_length which eventually calls
target_read.  So from gdb_insn_length and on, inferior_ptid and the rest of the
global context should be set appropriately.  I think that
btrace_compute_ftrace_bts should set and restore the current thread (ideally,
it should pass down the thread, but that's for another day).

Here's an untested patch (well, I tested it, the test still passes for me, but
I don't know if it fixes your regression):

diff --git a/gdb/btrace.c b/gdb/btrace.c
index 5e689c11d4bd..93e7bc438a7e 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1104,6 +1104,11 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
          size = 0;
          try
            {
+             /* gdb_insn_length will need to read memory from TP, which may
+                not be the current thread on entryt.  Make sure it is.  */
+             scoped_restore_current_thread restore_thread;
+             switch_to_thread (tp);
+
              size = gdb_insn_length (gdbarch, pc);
            }
          catch (const gdb_exception_error &error)

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-14 14:41 ` simark at simark dot ca
@ 2021-07-14 15:13 ` vries at gcc dot gnu.org
  2021-07-14 15:14 ` simark at simark dot ca
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14 15:13 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Simon Marchi from comment #4)
> Here's an untested patch (well, I tested it, the test still passes for me,
> but I don't know if it fixes your regression):

I've tried the patch, doesn't seem to fix it unfortunately.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-07-14 15:13 ` vries at gcc dot gnu.org
@ 2021-07-14 15:14 ` simark at simark dot ca
  2021-07-14 15:30 ` simark at simark dot ca
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: simark at simark dot ca @ 2021-07-14 15:14 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Simon Marchi <simark at simark dot ca> ---
As discussed on IRC, the key to reproducing is that GDB needs to be configured
_without_ libipt.

So I was able to reproduce and see that the patch doesn't fix it indeed.  But
at least now I can debug.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-07-14 15:14 ` simark at simark dot ca
@ 2021-07-14 15:30 ` simark at simark dot ca
  2021-07-14 15:34 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: simark at simark dot ca @ 2021-07-14 15:30 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from Simon Marchi <simark at simark dot ca> ---
The issue with the patch was that the switch_to_thread was in a too narrow
scope.  This works for me.  We should investigate if this would be needed for
btrace_compute_ftrace_pt as well (even if it happens to work today).  If so, it
could be done in the caller, btrace_compute_ftrace or btrace_compute_ftrace_1.

>From e1fc3728b950844f12cbfd5bed6b5bd317867cde Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Wed, 14 Jul 2021 11:11:25 -0400
Subject: [PATCH] fix

Change-Id: I4b56d1cb8fb4c5651ba9d1e4f0782c2a13ab28dd
---
 gdb/btrace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/btrace.c b/gdb/btrace.c
index 5e689c11d4bd..0e53c7de390e 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1052,6 +1052,11 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
                           const struct btrace_data_bts *btrace,
                           std::vector<unsigned int> &gaps)
 {
+       /* gdb_insn_length will need to read memory from TP, which may
+       not be the current thread on entryt.  Make sure it is.  */
+       scoped_restore_current_thread restore_thread;
+       switch_to_thread (tp);
+
   struct btrace_thread_info *btinfo;
   struct gdbarch *gdbarch;
   unsigned int blk;
-- 
2.26.2

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-07-14 15:30 ` simark at simark dot ca
@ 2021-07-14 15:34 ` vries at gcc dot gnu.org
  2021-07-19 13:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-14 15:34 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Simon Marchi from comment #7)
> The issue with the patch was that the switch_to_thread was in a too narrow
> scope.  This works for me.

Same here.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-07-14 15:34 ` vries at gcc dot gnu.org
@ 2021-07-19 13:45 ` cvs-commit at gcc dot gnu.org
  2021-07-19 13:45 ` simark at simark dot ca
  2021-10-12  9:41 ` vries at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-19 13:45 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ecd799b189aaf7c04fef0b6c1d74c5ac10ddfc0e

commit ecd799b189aaf7c04fef0b6c1d74c5ac10ddfc0e
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Wed Jul 14 16:31:09 2021 -0400

    gdb: set current thread in btrace_compute_ftrace_{bts,pt}

    As documented in bug 28086, test gdb.btrace/enable-new-thread.exp
    started failing with commit 0618ae414979 ("gdb: optimize
    all_matching_threads_iterator"):

        (gdb) record btrace^M
        (gdb) PASS: gdb.btrace/enable-new-thread.exp: record btrace
        break 24^M
        Breakpoint 2 at 0x555555555175: file
/home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.btrace/enable-new-thread.c,
line 24.^M
        (gdb) continue^M
        Continuing.^M
        /home/smarchi/src/binutils-gdb/gdb/inferior.c:303: internal-error:
inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0'
failed.^M
        A problem internal to GDB has been detected,^M
        further debugging may prove unreliable.^M
        Quit this debugging session? (y or n) FAIL:
gdb.btrace/enable-new-thread.exp: continue to breakpoint: cont to bp.1 (GDB
internal error)

    Note that I only see the failure if GDB is compiled without libipt
    support.  This is because GDB then makes use BTS instead of PT, so
    exercises different code paths.

    I think that the commit above just exposed an existing problem.  The
    stack trace of the internal error is:

        #8  0x0000561cb81e404e in internal_error (file=0x561cb83aa2f8
"/home/smarchi/src/binutils-gdb/gdb/inferior.c", line=303, fmt=0x561cb83aa099
"%s: Assertion `%s' failed.") at
/home/smarchi/src/binutils-gdb/gdbsupport/errors.cc:55
        #9  0x0000561cb7b5c031 in find_inferior_pid (targ=0x561cb8aafb60
<the_amd64_linux_nat_target>, pid=0) at
/home/smarchi/src/binutils-gdb/gdb/inferior.c:303
        #10 0x0000561cb7b5c102 in find_inferior_ptid (targ=0x561cb8aafb60
<the_amd64_linux_nat_target>, ptid=...) at
/home/smarchi/src/binutils-gdb/gdb/inferior.c:317
        #11 0x0000561cb7f1d1c3 in find_thread_ptid (targ=0x561cb8aafb60
<the_amd64_linux_nat_target>, ptid=...) at
/home/smarchi/src/binutils-gdb/gdb/thread.c:487
        #12 0x0000561cb7f1b921 in
all_matching_threads_iterator::all_matching_threads_iterator
(this=0x7ffc4ee34678, filter_target=0x561cb8aafb60
<the_amd64_linux_nat_target>, filter_ptid=...) at
/home/smarchi/src/binutils-gdb/gdb/thread-iter.c:125
        #13 0x0000561cb77bc462 in
filtered_iterator<all_matching_threads_iterator,
non_exited_thread_filter>::filtered_iterator<process_stratum_target* const&,
ptid_t const&> (this=0x7ffc4ee34670) at
/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/filtered-iterator.h:42
        #14 0x0000561cb77b97cb in all_non_exited_threads_range::begin
(this=0x7ffc4ee34650) at /home/smarchi/src/binutils-gdb/gdb/thread-iter.h:243
        #15 0x0000561cb7d8ba30 in record_btrace_target::record_is_replaying
(this=0x561cb8aa6250 <record_btrace_ops>, ptid=...) at
/home/smarchi/src/binutils-gdb/gdb/record-btrace.c:1411
        #16 0x0000561cb7d8bb83 in record_btrace_target::xfer_partial
(this=0x561cb8aa6250 <record_btrace_ops>, object=TARGET_OBJECT_MEMORY,
annex=0x0, readbuf=0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=0x0,
offset=140737352774277, len=1, xfered_len=0x7ffc4ee34ad8) at
/home/smarchi/src/binutils-gdb/gdb/record-btrace.c:1437
        #17 0x0000561cb7ef73a9 in raw_memory_xfer_partial (ops=0x561cb8aa6250
<record_btrace_ops>, readbuf=0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=0x0,
memaddr=140737352774277, len=1, xfered_len=0x7ffc4ee34ad8) at
/home/smarchi/src/binutils-gdb/gdb/target.c:1504
        #18 0x0000561cb7ef77da in memory_xfer_partial_1 (ops=0x561cb8aa6250
<record_btrace_ops>, object=TARGET_OBJECT_CODE_MEMORY, readbuf=0x7ffc4ee34c58
"\260g\343N\374\177", writebuf=0x0, memaddr=140737352774277, len=1,
xfered_len=0x7ffc4ee34ad8) at /home/smarchi/src/binutils-gdb/gdb/target.c:1635
        #19 0x0000561cb7ef78b5 in memory_xfer_partial (ops=0x561cb8aa6250
<record_btrace_ops>, object=TARGET_OBJECT_CODE_MEMORY, readbuf=0x7ffc4ee34c58
"\260g\343N\374\177", writebuf=0x0, memaddr=140737352774277, len=1,
xfered_len=0x7ffc4ee34ad8) at /home/smarchi/src/binutils-gdb/gdb/target.c:1664
        #20 0x0000561cb7ef7ba4 in target_xfer_partial (ops=0x561cb8aa6250
<record_btrace_ops>, object=TARGET_OBJECT_CODE_MEMORY, annex=0x0,
readbuf=0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=0x0,
offset=140737352774277, len=1, xfered_len=0x7ffc4ee34ad8) at
/home/smarchi/src/binutils-gdb/gdb/target.c:1721
        #21 0x0000561cb7ef8503 in target_read_partial (ops=0x561cb8aa6250
<record_btrace_ops>, object=TARGET_OBJECT_CODE_MEMORY, annex=0x0,
buf=0x7ffc4ee34c58 "\260g\343N\374\177", offset=140737352774277, len=1,
xfered_len=0x7ffc4ee34ad8) at /home/smarchi/src/binutils-gdb/gdb/target.c:1974
        #22 0x0000561cb7ef861f in target_read (ops=0x561cb8aa6250
<record_btrace_ops>, object=TARGET_OBJECT_CODE_MEMORY, annex=0x0,
buf=0x7ffc4ee34c58 "\260g\343N\374\177", offset=140737352774277, len=1) at
/home/smarchi/src/binutils-gdb/gdb/target.c:2014
        #23 0x0000561cb7ef809f in target_read_code (memaddr=140737352774277,
myaddr=0x7ffc4ee34c58 "\260g\343N\374\177", len=1) at
/home/smarchi/src/binutils-gdb/gdb/target.c:1869
        #24 0x0000561cb7937f4d in gdb_disassembler::dis_asm_read_memory
(memaddr=140737352774277, myaddr=0x7ffc4ee34c58 "\260g\343N\374\177", len=1,
info=0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/gdb/disasm.c:139
        #25 0x0000561cb80ab66d in fetch_data (info=0x7ffc4ee34e88,
addr=0x7ffc4ee34c59 "g\343N\374\177") at
/home/smarchi/src/binutils-gdb/opcodes/i386-dis.c:194
        #26 0x0000561cb80ab7e2 in ckprefix () at
/home/smarchi/src/binutils-gdb/opcodes/i386-dis.c:8628
        #27 0x0000561cb80adbd8 in print_insn (pc=140737352774277,
info=0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/opcodes/i386-dis.c:9587
        #28 0x0000561cb80abe4f in print_insn_i386 (pc=140737352774277,
info=0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/opcodes/i386-dis.c:8894
        #29 0x0000561cb7744a19 in default_print_insn (memaddr=140737352774277,
info=0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/gdb/arch-utils.c:1029
        #30 0x0000561cb7b33067 in i386_print_insn (pc=140737352774277,
info=0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/gdb/i386-tdep.c:4013
        #31 0x0000561cb7acd8f4 in gdbarch_print_insn (gdbarch=0x561cbae2fb60,
vma=140737352774277, info=0x7ffc4ee34e88) at
/home/smarchi/src/binutils-gdb/gdb/gdbarch.c:3478
        #32 0x0000561cb793a32d in gdb_disassembler::print_insn
(this=0x7ffc4ee34e80, memaddr=140737352774277, branch_delay_insns=0x0) at
/home/smarchi/src/binutils-gdb/gdb/disasm.c:795
        #33 0x0000561cb793a5b0 in gdb_print_insn (gdbarch=0x561cbae2fb60,
memaddr=140737352774277, stream=0x561cb8ac99f8 <null_stream>,
branch_delay_insns=0x0) at /home/smarchi/src/binutils-gdb/gdb/disasm.c:850
        #34 0x0000561cb793a631 in gdb_insn_length (gdbarch=0x561cbae2fb60,
addr=140737352774277) at /home/smarchi/src/binutils-gdb/gdb/disasm.c:859
        #35 0x0000561cb77f53f4 in btrace_compute_ftrace_bts (tp=0x561cbba11210,
btrace=0x7ffc4ee35188, gaps=...) at
/home/smarchi/src/binutils-gdb/gdb/btrace.c:1107
        #36 0x0000561cb77f55f5 in btrace_compute_ftrace_1 (tp=0x561cbba11210,
btrace=0x7ffc4ee35180, cpu=0x0, gaps=...) at
/home/smarchi/src/binutils-gdb/gdb/btrace.c:1527
        #37 0x0000561cb77f5705 in btrace_compute_ftrace (tp=0x561cbba11210,
btrace=0x7ffc4ee35180, cpu=0x0) at
/home/smarchi/src/binutils-gdb/gdb/btrace.c:1560
        #38 0x0000561cb77f583b in btrace_add_pc (tp=0x561cbba11210) at
/home/smarchi/src/binutils-gdb/gdb/btrace.c:1589
        #39 0x0000561cb77f5a86 in btrace_enable (tp=0x561cbba11210,
conf=0x561cb8ac6878 <record_btrace_conf>) at
/home/smarchi/src/binutils-gdb/gdb/btrace.c:1629
        #40 0x0000561cb7d88d26 in record_btrace_enable_warn (tp=0x561cbba11210)
at /home/smarchi/src/binutils-gdb/gdb/record-btrace.c:294
        #41 0x0000561cb7c603dc in std::__invoke_impl<void, void
(*&)(thread_info*), thread_info*> (__f=@0x561cbb6c4878: 0x561cb7d88cdc
<record_btrace_enable_warn(thread_info*)>) at
/usr/include/c++/10/bits/invoke.h:60
        #42 0x0000561cb7c5e5a6 in std::__invoke_r<void, void
(*&)(thread_info*), thread_info*> (__fn=@0x561cbb6c4878: 0x561cb7d88cdc
<record_btrace_enable_warn(thread_info*)>) at
/usr/include/c++/10/bits/invoke.h:153
        #43 0x0000561cb7c5dc92 in std::_Function_handler<void (thread_info*),
void (*)(thread_info*)>::_M_invoke(std::_Any_data const&, thread_info*&&)
(__functor=..., __args#0=@0x7ffc4ee35310: 0x561cbba11210) at
/usr/include/c++/10/bits/std_function.h:291
        #44 0x0000561cb7f2600f in std::function<void
(thread_info*)>::operator()(thread_info*) const (this=0x561cbb6c4878,
__args#0=0x561cbba11210) at /usr/include/c++/10/bits/std_function.h:622
        #45 0x0000561cb7f23dc8 in
gdb::observers::observable<thread_info*>::notify (this=0x561cb8ac5aa0
<gdb::observers::new_thread>, args#0=0x561cbba11210) at
/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/observable.h:150
        #46 0x0000561cb7f1c436 in add_thread_silent (targ=0x561cb8aafb60
<the_amd64_linux_nat_target>, ptid=...) at
/home/smarchi/src/binutils-gdb/gdb/thread.c:263
        #47 0x0000561cb7f1c479 in add_thread_with_info (targ=0x561cb8aafb60
<the_amd64_linux_nat_target>, ptid=..., priv=0x561cbb3f7ab0) at
/home/smarchi/src/binutils-gdb/gdb/thread.c:272
        #48 0x0000561cb7bfa1d0 in record_thread (info=0x561cbb0413a0, tp=0x0,
ptid=..., th_p=0x7ffc4ee35610, ti_p=0x7ffc4ee35620) at
/home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:1380
        #49 0x0000561cb7bf7a2a in thread_from_lwp (stopped=0x561cba81db20,
ptid=...) at /home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:429
        #50 0x0000561cb7bf7ac5 in thread_db_notice_clone (parent=...,
child=...) at /home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:447
        #51 0x0000561cb7bdc9a2 in linux_handle_extended_wait
(lp=0x561cbae25720, status=4991) at
/home/smarchi/src/binutils-gdb/gdb/linux-nat.c:1981
        #52 0x0000561cb7bdf0f3 in linux_nat_filter_event (lwpid=435403,
status=198015) at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:2920
        #53 0x0000561cb7bdfed6 in linux_nat_wait_1 (ptid=...,
ourstatus=0x7ffc4ee36398, target_options=...) at
/home/smarchi/src/binutils-gdb/gdb/linux-nat.c:3202
        #54 0x0000561cb7be0b68 in linux_nat_target::wait (this=0x561cb8aafb60
<the_amd64_linux_nat_target>, ptid=..., ourstatus=0x7ffc4ee36398,
target_options=...) at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:3440
        #55 0x0000561cb7bfa2fc in thread_db_target::wait (this=0x561cb8a9acd0
<the_thread_db_target>, ptid=..., ourstatus=0x7ffc4ee36398, options=...) at
/home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:1412
        #56 0x0000561cb7d8e356 in record_btrace_target::wait
(this=0x561cb8aa6250 <record_btrace_ops>, ptid=..., status=0x7ffc4ee36398,
options=...) at /home/smarchi/src/binutils-gdb/gdb/record-btrace.c:2547
        #57 0x0000561cb7ef996d in target_wait (ptid=..., status=0x7ffc4ee36398,
options=...) at /home/smarchi/src/binutils-gdb/gdb/target.c:2608
        #58 0x0000561cb7b6d297 in do_target_wait_1 (inf=0x561cba6d8780,
ptid=..., status=0x7ffc4ee36398, options=...) at
/home/smarchi/src/binutils-gdb/gdb/infrun.c:3640
        #59 0x0000561cb7b6d43e in operator() (__closure=0x7ffc4ee36190,
inf=0x561cba6d8780) at /home/smarchi/src/binutils-gdb/gdb/infrun.c:3701
        #60 0x0000561cb7b6d7b2 in do_target_wait (ecs=0x7ffc4ee36370,
options=...) at /home/smarchi/src/binutils-gdb/gdb/infrun.c:3720
        #61 0x0000561cb7b6e67d in fetch_inferior_event () at
/home/smarchi/src/binutils-gdb/gdb/infrun.c:4069
        #62 0x0000561cb7b4659b in inferior_event_handler
(event_type=INF_REG_EVENT) at /home/smarchi/src/binutils-gdb/gdb/inf-loop.c:41
        #63 0x0000561cb7be25f7 in handle_target_event (error=0,
client_data=0x0) at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:4227
        #64 0x0000561cb81e4ee2 in handle_file_event (file_ptr=0x561cbae24e10,
ready_mask=1) at /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:575
        #65 0x0000561cb81e5490 in gdb_wait_for_event (block=0) at
/home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:701
        #66 0x0000561cb81e41be in gdb_do_one_event () at
/home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:212
        #67 0x0000561cb7c18096 in start_event_loop () at
/home/smarchi/src/binutils-gdb/gdb/main.c:421
        #68 0x0000561cb7c181e0 in captured_command_loop () at
/home/smarchi/src/binutils-gdb/gdb/main.c:481
        #69 0x0000561cb7c19d7e in captured_main (data=0x7ffc4ee366a0) at
/home/smarchi/src/binutils-gdb/gdb/main.c:1353
        #70 0x0000561cb7c19df0 in gdb_main (args=0x7ffc4ee366a0) at
/home/smarchi/src/binutils-gdb/gdb/main.c:1368
        #71 0x0000561cb7693186 in main (argc=11, argv=0x7ffc4ee367b8) at
/home/smarchi/src/binutils-gdb/gdb/gdb.c:32

    At frame 45, the new_thread observable is fired.  At this moment, the
    new thread isn't the current thread, inferior_ptid is null_ptid.  I
    think this is ok: the new_thread observable doesn't give any guarantee
    on the global context when observers are invoked.  Frame 35,
    btrace_compute_ftrace_bts, calls gdb_insn_length.  gdb_insn_length
    doesn't have a thread_info or other parameter what could indicate where
    to read memory from, it implicitly uses the global context
    (inferior_ptid).

    So we reach the all_non_exited_threads_range in
    record_btrace_target::record_is_replaying with a null inferior_ptid.
    The previous implemention of all_non_exited_threads_range didn't care,
    but the new one does.  The problem of calling gdb_insn_length and
    ultimately trying to read memory with a null inferior_ptid already
    existed, but the commit mentioned above made it visible.

    Something between frames 40 (record_btrace_enable_warn) and 35
    (btrace_compute_ftrace_bts) needs to be switching the global context to
    make TP the current thread.  Since btrace_compute_ftrace_bts takes the
    thread_info to work with as a parameter, that typically means that it
    doesn't require its caller to also set the global current context
    (current thread) when calling.  If it needs to call other functions
    that do require the global current thread to be set, then it needs to
    temporarily change the current thread while calling these other
    functions.  Therefore, switch and restore the current thread in
    btrace_compute_ftrace_bts.

    By inspection, it looks like btrace_compute_ftrace_pt may also call
    functions sensitive to the global context: it installs the
    btrace_pt_readmem_callback callback in the PT instruction decoder.  When
    this function gets called, inferior_ptid must be set appropriately.  Add
    a switch and restore in there too.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28086
    Change-Id: I407fbfe41aab990068bd102491aa3709b0a034b3

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2021-07-19 13:45 ` cvs-commit at gcc dot gnu.org
@ 2021-07-19 13:45 ` simark at simark dot ca
  2021-10-12  9:41 ` vries at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: simark at simark dot ca @ 2021-07-19 13:45 UTC (permalink / raw)
  To: gdb-prs

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

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #10 from Simon Marchi <simark at simark dot ca> ---
Fixed by that ^.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed.
  2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2021-07-19 13:45 ` simark at simark dot ca
@ 2021-10-12  9:41 ` vries at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-10-12  9:41 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #11 from Tom de Vries <vries at gcc dot gnu.org> ---
FTR, filed PR28445 - "inferior.c:300: internal-error: inferior*
find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed",
which looks similar.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-10-12  9:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  7:12 [Bug record/28086] New: inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed vries at gcc dot gnu.org
2021-07-14  7:12 ` [Bug record/28086] " vries at gcc dot gnu.org
2021-07-14  7:14 ` vries at gcc dot gnu.org
2021-07-14  7:19 ` vries at gcc dot gnu.org
2021-07-14  9:33 ` vries at gcc dot gnu.org
2021-07-14 14:41 ` simark at simark dot ca
2021-07-14 15:13 ` vries at gcc dot gnu.org
2021-07-14 15:14 ` simark at simark dot ca
2021-07-14 15:30 ` simark at simark dot ca
2021-07-14 15:34 ` vries at gcc dot gnu.org
2021-07-19 13:45 ` cvs-commit at gcc dot gnu.org
2021-07-19 13:45 ` simark at simark dot ca
2021-10-12  9:41 ` vries at gcc dot gnu.org

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).