Discussion:
[Bug gdb/23039] New: 'info program' always cause GDB aborts at early start
paxav at banit dot club
2018-04-08 10:34:41 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23039

Bug ID: 23039
Summary: 'info program' always cause GDB aborts at early start
Product: gdb
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: paxav at banit dot club
Target Milestone: ---

Issuing 'info program' at early start (e.g by setting an invalid breakpoint
then run) will always cause GDB abort (in all versions). Below are steps to
reproduce:

$ gdb -n /bin/ls
GNU gdb (Ubuntu 8.0.1-0ubuntu3) 8.0.1
Copyright (C) 2017 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-linux-gnu".
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"...
Reading symbols from /bin/ls...(no debugging symbols found)...done.
(gdb) b *0
Breakpoint 1 at 0x0
(gdb) r
Starting program: /bin/ls
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x0

(gdb) info program
/build/gdb-dBkf_h/gdb-8.0.1/gdb/thread.c:1005: internal-error: int
is_thread_state(ptid_t, 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

This is a bug, please report it. For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.

/build/gdb-dBkf_h/gdb-8.0.1/gdb/thread.c:1005: internal-error: int
is_thread_state(ptid_t, 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
[1] 13430 abort (core dumped) gdb -n /bin/ls
--
You are receiving this mail because:
You are on the CC list for the bug.
paxav at banit dot club
2018-04-08 10:35:18 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23039

paxav at banit dot club changed:

What |Removed |Added
----------------------------------------------------------------------------
Version|unknown |8.0.1
--
You are receiving this mail because:
You are on the CC list for the bug.
weimin.pan at oracle dot com
2018-11-15 23:09:25 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23039

weimin.pan at oracle dot com changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |weimin.pan at oracle dot com

--- Comment #1 from weimin.pan at oracle dot com ---
The crash could easily be reproduced. Setting breakpoint at 0 causes
insert_breakpoint_locations to fail and find_thread_ptid to return a
NULL thread_info pointer in info_program_command. Dereferencing the
NULL pointer then triggers the crash.

Checking the return value from the find_thread_ptid call before
dereferencing it is one way to fix the problem.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-11-16 21:42:45 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23039

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |sergiodj at redhat dot com

--- Comment #2 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
This has been reported before, on Bug 16392. At the time (2014), I submitted a
patch to fix the problem:

https://sourceware.org/ml/gdb-patches/2014-01/msg00709.html

But never followed up on it.

I'm inclined to close this bug as a duplicate of Bug 16392, but decided to
consult with you guys first.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-11-16 16:34:25 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23039

--- Comment #3 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
What's interesting is that I can't actually reproduce this bug using git HEAD.

When "run" is issued, GDB actually goes to the background (due to a SIGTTOU, as
far as I have investigated) and, when brought back to the foreground, "info
program" doesn't crash.

I'd be interested in knowing if you can reproduce this bug using the latest
version on the git repository. Thanks.
--
You are receiving this mail because:
You are on the CC list for the bug.
weimin.pan at oracle dot com
2018-11-16 17:58:07 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23039

--- Comment #4 from weimin.pan at oracle dot com ---
I still can reproduce the crash with a gdb that is not the latest version
on git repository:

% ~/binutils-gdb/gdb/gdb a.out
GNU gdb (GDB) 8.2.50.20181008-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
...
Reading symbols from a.out...
(gdb) b *0
Breakpoint 1 at 0x0
(gdb) r
Starting program: a.out

[19]+ Stopped ~/binutils-gdb/gdb/gdb a.out
% fg
~/binutils-gdb/gdb/gdb a.out
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x0

(gdb) i program
Segmentation fault
%
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...