Bug#1034611: Working patch found

2023-04-22 Thread Adit Sahasrabudhe
Looks like this is the same bug as reported here:

https://www.cygwin.com/bugzilla/show_bug.cgi?id=30240

And I tested the patch at this link and it worked.

https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=b3eff3e15576229af9bae026c5c23ee694b90389


Bug#1034611:

2023-04-19 Thread Adit Sahasrabudhe
Also I should note that there are no kernel messages in dmesg when this
happens.


Bug#1034611: arm64: thread.c:85: Assertion `current_thread_ != nullptr'

2023-04-19 Thread Adit Sahasrabudhe
Package: gdb
Version: 13.1-2
Severity: important

Dear Maintainer,

On my bookworm install (in a Parallels VM), any attempt to debug a program 
results in the error:

thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != 
nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

I downloaded v13.1 source, and built it with "-g -O0", and here is the 
backtrace I get when running a simple hello world:

- Backtrace -
0xcee2ff5b gdb_internal_backtrace_1
/home/asahasra/code/gdb-13.1/gdb/bt-utils.c:122
0xcee2ff5b _Z22gdb_internal_backtracev
/home/asahasra/code/gdb-13.1/gdb/bt-utils.c:168
0xcf1802ef internal_vproblem
/home/asahasra/code/gdb-13.1/gdb/utils.c:396
0xcf180553 _Z15internal_verrorPKciS0_St9__va_list
/home/asahasra/code/gdb-13.1/gdb/utils.c:476
0xcf3f33e3 _Z18internal_error_locPKciS0_z
/home/asahasra/code/gdb-13.1/gdbsupport/errors.cc:58
0xcf13a527 _Z15inferior_threadv
/home/asahasra/code/gdb-13.1/gdb/thread.c:85
0xcf13b0ff _Z15inferior_threadv
/home/asahasra/code/gdb-13.1/gdb/thread.c:84
0xcf085ddb _Z20get_current_regcachev
/home/asahasra/code/gdb-13.1/gdb/regcache.c:428
0xced7e8f3 aarch64_remove_non_address_bits
/home/asahasra/code/gdb-13.1/gdb/aarch64-linux-tdep.c:2002
0xcf135767 memory_xfer_partial
/home/asahasra/code/gdb-13.1/gdb/target.c:1620
0xcf135767 _Z19target_xfer_partialP10target_ops13target_objectPKcPhPKhmmPm
/home/asahasra/code/gdb-13.1/gdb/target.c:1684
0xcf135c77 target_read_partial
/home/asahasra/code/gdb-13.1/gdb/target.c:1937
0xcf135c77 _Z11target_readP10target_ops13target_objectPKcPhml
/home/asahasra/code/gdb-13.1/gdb/target.c:1977
0xcf135d27 _Z18target_read_memorymPhl
/home/asahasra/code/gdb-13.1/gdb/target.c:1773
0xcf02fb77 ps_xfer_memory
/home/asahasra/code/gdb-13.1/gdb/proc-service.c:90
0xa8085387 _td_fetch_value
./nptl_db/fetch-value.c:115
0xa808230f td_ta_map_lwp2thr
./nptl_db/td_ta_map_lwp2thr.c:194
0xcefbfb53 thread_from_lwp
/home/asahasra/code/gdb-13.1/gdb/linux-thread-db.c:413
0xcefc1107 
_ZN16thread_db_target4waitE6ptid_tP17target_waitstatus10enum_flagsI16target_wait_flagE
/home/asahasra/code/gdb-13.1/gdb/linux-thread-db.c:1420
0xcf137d5f 
_Z11target_wait6ptid_tP17target_waitstatus10enum_flagsI16target_wait_flagE
/home/asahasra/code/gdb-13.1/gdb/target.c:2579
0xcef830d3 do_target_wait_1
/home/asahasra/code/gdb-13.1/gdb/infrun.c:3736
0xcef93197 operator()
/home/asahasra/code/gdb-13.1/gdb/infrun.c:3795
0xcef93197 do_target_wait
/home/asahasra/code/gdb-13.1/gdb/infrun.c:3814
0xcef93197 _Z20fetch_inferior_eventv
/home/asahasra/code/gdb-13.1/gdb/infrun.c:4172
0xcf3f3863 gdb_wait_for_event
/home/asahasra/code/gdb-13.1/gdbsupport/event-loop.cc:716
0xcf3f4357 _Z16gdb_do_one_eventi
/home/asahasra/code/gdb-13.1/gdbsupport/event-loop.cc:217
0xcefd1e8f start_event_loop
/home/asahasra/code/gdb-13.1/gdb/main.c:411
0xcefd1e8f captured_command_loop
/home/asahasra/code/gdb-13.1/gdb/main.c:471
0xcefd3893 captured_main
/home/asahasra/code/gdb-13.1/gdb/main.c:1330
0xcefd3893 _Z8gdb_mainP18captured_main_args
/home/asahasra/code/gdb-13.1/gdb/main.c:1345
0xced758f3 main
/home/asahasra/code/gdb-13.1/gdb/gdb.c:32
-

I enabled thread debugging in thread.c and before the assertion, this is what I 
see:

Starting program: /home/asahasra/code/hello/hello
[threads] add_thread_silent: add thread to inferior 1, ptid 1023755.0.0, target 
native
[threads] new_thread: creating a new thread object, inferior 1, ptid 1023755.0.0
[threads] switch_to_thread_no_regs: thread = 1023755.0.0
[threads] set_running_thread: thread: 1023755.1023755.0, running? 1 (started)
[threads] switch_to_thread_no_regs: thread = 1023755.1023755.0
[threads] switch_to_thread_no_regs: thread = 1023755.1023755.0
[threads] switch_to_no_thread: thread = NONE
[threads] switch_to_thread_no_regs: thread = 1023755.1023755.0
[threads] switch_to_no_thread: thread = NONE
[threads] switch_to_thread_no_regs: thread = 1023755.1023755.0
[threads] switch_to_no_thread: thread = NONE

The above two statements repeat many times before the assert hits.

Lastly, I tried two other tags:
gdb-12.1-release - this seems to work fine
gdb-13-branchpoint - this fails

That hopefully helps narrow down which commit broke this.


-- System Information:
Debian Release: 12.0
  APT prefers testing-security
  APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: arm64 (aarch64)
Foreign Architectures: amd64

Kernel: Linux 6.1.0-7-arm64 (SMP w/6 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8