NetBSD Problem Report #48743

From wiz@yt.nih.at  Sun Apr 13 18:05:41 2014
Return-Path: <wiz@yt.nih.at>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 9D0CDA5810
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 13 Apr 2014 18:05:41 +0000 (UTC)
Message-Id: <20140413171752.92DB02AC10E@yt.nih.at>
Date: Sun, 13 Apr 2014 19:17:52 +0200 (CEST)
From: Thomas Klausner <wiz@NetBSD.org>
Reply-To: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Subject: gdb: quitting after attaching to process doesn't work
X-Send-Pr-Version: 3.95

>Number:         48743
>Category:       toolchain
>Synopsis:       gdb: quitting after attaching to process doesn't work
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 13 18:10:00 +0000 2014
>Closed-Date:    Fri Oct 06 21:42:35 +0000 2017
>Last-Modified:  Fri Oct 06 23:00:01 +0000 2017
>Originator:     Thomas Klausner
>Release:        NetBSD 6.99.40
>Organization:
Curiosity is the very basis of education and if you tell me that 
curiosity killed the cat, I say only that the cat died nobly.
- Arnold Edinborough
>Environment:


Architecture: x86_64
Machine: amd64
>Description:
I was just looking at an I think single-threaded program. Just
attached to a running process and did 'thread apply all bt' which just
gave me one thread's backtrace.

Then I tried leaving gdb:

(gdb) quit
A debugging session is active.

        Inferior 1 [LWP 0] will be detached.

Quit anyway? (y or n) y

/archive/foreign/src/external/gpl3/gdb/dist/gdb/thread.c:615: internal-error: int is_thread_state(ptid_t, enum thread_state): Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y
/archive/foreign/src/external/gpl3/gdb/dist/gdb/thread.c:615: internal-error: int is_thread_state(ptid_t, enum thread_state): Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y
sorry, pid 860 was killed: orphaned traced process
zsh: abort (core dumped)  gdb debugallocation_test 860
# gdb gdb.core
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/gdb...done.
[New process 1]

warning: Can't read pathname for load map: Input/output error.
Core was generated by `gdb'.
Program terminated with signal 6, Aborted.
#0  0x00007f7ff552322a in _lwp_kill () from /usr/lib/libc.so.12
(gdb) bt
#0  0x00007f7ff552322a in _lwp_kill () from /usr/lib/libc.so.12
#1  0x00007f7ff5522e5b in abort () at /archive/foreign/src/lib/libc/stdlib/abort.c:74
#2  0x00000000004cc096 in dump_core () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/utils.c:761
#3  0x00000000004c801a in internal_vproblem (problem=<optimized out>, file=<optimized out>, line=<optimized out>, fmt=<optimized out>, ap=<optimized out>)
    at /archive/foreign/src/external/gpl3/gdb/dist/gdb/utils.c:929
#4  0x00000000004c7d7c in internal_verror (file=0x6 <Address 0x6 out of bounds>, line=0, fmt=0x7f7ff552322a <_lwp_kill+10> "r\001\303\351\016", ap=0x3e)
    at /archive/foreign/src/external/gpl3/gdb/dist/gdb/utils.c:944
#5  0x00000000004c76a4 in internal_error (file=0x1 <Address 0x1 out of bounds>, warning: Unmapped DWARF Register #-2 encountered.
line=<error reading variable: Unable to access DWARF register number 0xfffffffe>, string=0x0)
    at /archive/foreign/src/external/gpl3/gdb/dist/gdb/utils.c:954
#6  0x000000000053562c in is_thread_state (state=<optimized out>, ptid=..., state=<optimized out>) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/thread.c:615
#7  is_stopped (ptid=...) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/thread.c:622
#8  make_cleanup_restore_current_thread () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/thread.c:1142
#9  0x00000000004a9c54 in save_current_space_and_thread () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/progspace.c:475
#10 0x00000000004522eb in prepare_re_set_context (b=<optimized out>) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/breakpoint.c:14425
#11 breakpoint_re_set_one (bint=0x7f7ff7b3b400) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/breakpoint.c:14444
#12 0x00000000004a1815 in catch_errors (func=0x4522d0 <breakpoint_re_set_one>, func_args=0x7f7ff7b3b400, errstring=0x7f7ff77399e0 "Error in re-setting breakpoint -3: ", mask=6)
    at /archive/foreign/src/external/gpl3/gdb/dist/gdb/exceptions.c:546
#13 0x000000000044eb3b in breakpoint_re_set () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/breakpoint.c:14469
#14 0x000000000041923c in clear_symtab_users (add_flags=<optimized out>) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/symfile.c:2926
#15 0x00000000004197ed in symbol_file_clear (from_tty=0) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/symfile.c:1300
#16 0x000000000055f903 in nbsd_thread_detach (ops=0xabfe08 <nbsd_thread_ops>, args=0x0, from_tty=1) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/nbsd-thread.c:210
#17 0x000000000050f019 in target_detach (args=0x0, from_tty=1) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/target.c:2603
#18 0x00000000004cdcf3 in kill_or_detach (inf=<optimized out>, args=0x7f7fffffd1e8) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/top.c:1214
#19 0x00000000004aca69 in iterate_over_inferiors (callback=0x4cdca0 <kill_or_detach>, data=0x7f7fffffd1e8) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/inferior.c:395
#20 0x00000000004cd254 in quit_target (arg=0x6) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/top.c:1295
#21 0x00000000004a1815 in catch_errors (func=0x4cd240 <quit_target>, func_args=0x7f7fffffd1e8, errstring=0x70bdcf "Quitting: ", mask=6) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/exceptions.c:546
#22 0x00000000004cd230 in quit_force (args=0x0, from_tty=1) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/top.c:1333
#23 0x00000000004cc4bb in execute_command (p=0x6ebabf "", from_tty=<optimized out>) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/top.c:484
#24 0x000000000052ad82 in command_handler (command=0x0) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/event-top.c:426
#25 0x000000000052a9ca in command_line_handler (rl=<optimized out>) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/event-top.c:500
#26 0x0000000000689933 in rl_callback_read_char () at /archive/foreign/src/external/gpl3/gdb/dist/readline/callback.c:220
#27 0x000000000052a8a9 in rl_callback_read_char_wrapper (client_data=0x1) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/event-top.c:163
#28 0x000000000052b55c in process_event () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/event-loop.c:342
#29 0x000000000052b488 in gdb_do_one_event () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/event-loop.c:406
#30 0x000000000052b995 in start_event_loop () at /archive/foreign/src/external/gpl3/gdb/dist/gdb/event-loop.c:431
#31 0x00000000004074d3 in captured_command_loop (data=0x1) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/main.c:258
#32 0x00000000004a1815 in catch_errors (func=0x4074c0 <captured_command_loop>, func_args=0x0, errstring=0x6f5a4b "", mask=6) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/exceptions.c:546
#33 0x0000000000406fd6 in captured_main (data=<optimized out>) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/main.c:1041
#34 0x00000000004a1815 in catch_errors (func=0x406200 <captured_main>, func_args=0x7f7fffffd560, errstring=0x6f5a4b "", mask=6) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/exceptions.c:546
#35 0x00000000004061f7 in gdb_main (args=0x0) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/main.c:1050
#36 0x0000000000406116 in main (argc=<optimized out>, argv=0x6) at /archive/foreign/src/external/gpl3/gdb/dist/gdb/gdb.c:34
(gdb)

On NetBSD-6.99.32/amd64 from Sunday, and still on 6.99.40/amd64 from today.
All compiled with clang, in case it matters.

>How-To-Repeat:
start a program, e.g.
python2.7

While it's running, attach to it using
gdb python2.7 <PID>

leave gdb by pressing 'q'

It does work for /bin/cat, so it's not all programs that are broken this way,
but all programs I wanted to debug :)

>Fix:


>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: kamil@NetBSD.org
State-Changed-When: Fri, 06 Oct 2017 23:42:35 +0200
State-Changed-Why:

It works now:

$ gdb -p 17907 
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 17907
Reading symbols from /usr/pkg/bin/python2.7...done.
Reading symbols from /usr/pkg/lib/libpython2.7.so.1.0...done.
Reading symbols from /usr/lib/libutil.so.7...Reading symbols from /usr/libdata/debug//usr/lib/libutil.so.7.24.debug...done.
done.
Reading symbols from /usr/lib/libm.so.0...Reading symbols from /usr/libdata/debug//usr/lib/libm.so.0.12.debug...done.
done.
Reading symbols from /usr/lib/libpthread.so.1...Reading symbols from /usr/libdata/debug//usr/lib/libpthread.so.1.3.debug...done.
done.
Reading symbols from /usr/lib/libc.so.12...Reading symbols from /usr/libdata/debug//usr/lib/libc.so.12.207.debug...done.
done.
Reading symbols from /usr/pkg/lib/python2.7/lib-dynload/_locale.so...done.
Reading symbols from /usr/lib/libintl.so.1...Reading symbols from /usr/libdata/debug//usr/lib/libintl.so.1.1.debug...done.
done.
Reading symbols from /usr/lib/i18n/libUTF8.so.5.0...Reading symbols from /usr/libdata/debug//usr/lib/i18n/libUTF8.so.5.0.debug...done.
done.
Reading symbols from /usr/pkg/lib/python2.7/lib-dynload/readline.so...done.
Reading symbols from /usr/pkg/lib/libreadline.so.7...done.
Reading symbols from /usr/lib/libterminfo.so.1...Reading symbols from /usr/libdata/debug//usr/lib/libterminfo.so.1.0.debug...done.
done.
Reading symbols from /libexec/ld.elf_so...Reading symbols from /usr/libdata/debug//libexec/ld.elf_so.debug...done.
done.
[Switching to LWP 1]
0x0000794de223b30a in _sys___select50 () from /usr/lib/libc.so.12
(gdb) bt
#0  0x0000794de223b30a in _sys___select50 () from /usr/lib/libc.so.12
#1  0x0000794de260736f in __select50 (nfds=<optimized out>, readfds=<optimized out>, writefds=<optimized out>, 
    exceptfds=<optimized out>, timeout=<optimized out>) at /usr/src/lib/libpthread/pthread_cancelstub.c:514
#2  0x0000794de12037a2 in readline_until_enter_or_signal (prompt=<optimized out>, signal=0x7f7fff1c4984) at Modules/readline.c:1045
#3  0x0000794de1202b67 in call_readline (sys_stdin=0x794de255aec0 <__sF>, sys_stdout=0x794de255af58 <__sF+152>, 
    prompt=0x794de2ce97d4 ">>> ") at Modules/readline.c:1142
#4  0x0000794de3242ca9 in PyOS_Readline (sys_stdin=0x794de255aec0 <__sF>, sys_stdout=0x794de255af58 <__sF+152>, 
    prompt=0x794de2ce97d4 ">>> ") at Parser/myreadline.c:207
#5  0x0000794de324474a in tok_nextc (tok=0x794de2956c00) at Parser/tokenizer.c:884
#6  0x0000794de324340f in tok_get (tok=0x794de2956c00, p_start=0x7f7fff1c4b48, p_end=0x7f7fff1c4b30) at Parser/tokenizer.c:1232
#7  0x0000794de324333e in PyTokenizer_Get (tok=0x794de2956c00, p_start=0x7f7fff1c4910, p_end=0x0) at Parser/tokenizer.c:1681
#8  0x0000794de32408dd in parsetok (tok=0x794de2956c00, g=<optimized out>, start=<optimized out>, err_ret=0x7f7fff1c4ba8, 
    flags=0x7f7fff1c4bd4) at Parser/parsetok.c:159
#9  0x0000794de32e53ca in PyParser_ASTFromFile (fp=0x1, filename=0x794de332ac1a "<stdin>", start=-500976886, 
    ps1=0x1a1 <error: Cannot access memory at address 0x1a1>, ps2=0x0, flags=0x7f7fff1c4d98, errcode=0x7f7fff1c4bd4, 
    arena=0x794de223b30a <_sys___select50+10>) at Python/pythonrun.c:1499
---Type <return> to continue, or q <return> to quit---
#10 0x0000794de32e5231 in PyRun_InteractiveOneFlags (fp=0x794de255aec0 <__sF>, filename=0x794de332ac1a "<stdin>", 
    flags=0x7f7fff1c4d98) at Python/pythonrun.c:837
#11 0x0000794de32e4e2e in PyRun_InteractiveLoopFlags (fp=0x794de255aec0 <__sF>, filename=0x794de332ac1a "<stdin>", 
    flags=0x7f7fff1c4d98) at Python/pythonrun.c:777
#12 0x0000794de32e4d2c in PyRun_AnyFileExFlags (fp=0x794de255aec0 <__sF>, filename=0x794de332ac1a "<stdin>", closeit=0, 
    flags=0x7f7fff1c4d98) at Python/pythonrun.c:746
#13 0x0000794de32f4b96 in Py_Main (argc=<optimized out>, argv=0x7f7fff1c4e08) at Modules/main.c:640
#14 0x000000000040086b in ___start ()
#15 0x0000794de3630000 in ?? ()
#16 0x0000000000000001 in ?? ()
#17 0x00007f7fff1c53d8 in ?? ()
#18 0x0000000000000000 in ?? ()
(gdb) q
A debugging session is active.

	Inferior 1 [LWP 0] will be detached.

Quit anyway? (y or n) y
Detaching from program: /usr/pkg/bin/python2.7, process 17907

$ uname -a
NetBSD rugged 8.99.1 NetBSD 8.99.1 (GENERIC) #7: Mon Jul  3 15:56:30 CEST 2017  root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64

Closing as is, it has been fixed since the origination.


From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: Kamil Rytarowski <n54@gmx.com>
Subject: Re: toolchain/48743 (gdb: quitting after attaching to process
 doesn't work)
Date: Sat, 7 Oct 2017 00:58:17 +0200

 Yes, worked for me recently as well. Thanks for working on this, kamil!
  Thomas

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.