Bug 12442 - internal-error: find_inferior_pid: Assertion `pid != 0' failed.
Summary: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
Status: RESOLVED WORKSFORME
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-26 11:10 UTC by Jonathan Wakely
Modified: 2015-01-17 20:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2011-01-26 11:10:08 UTC
GDB gets an internal error following these steps:

1) load an executable which segfaults and corresponding core file
2) run the executable
3) quit gdb

Here is the output of such a debugging session, using GDB 7.2 on CentOS 5.3

$ cat core.c
int main()
{
    char* p = 0;
    return *p;
}

$ gcc -g core.c
$
$ ./a.out
Segmentation fault (core dumped)
$
$ # lastcore just prints the name of the most recent core file
$ gdb -n ./a.out `lastcore`
GNU gdb (GDB) 7.2
Copyright (C) 2010 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-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /dev/shm/jwakely/a.out...done.
[New Thread 13830]
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000400464 in main () at core.c:4
4           return *p;
(gdb) r
Starting program: /dev/shm/jwakely/a.out

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400464 in main () at core.c:4
4           return *p;
(gdb) q
A debugging session is active.

        Inferior 1 [process 13880] will be killed.

Quit anyway? (y or n) y

inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y
inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

$
$ gdb --version
GNU gdb (GDB) 7.2
Copyright (C) 2010 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-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
$
$
$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /var/tmp/gcc/gcc-4.4.3/configure --prefix=/opt/gcc-4.4-64/gcc-4.4.3 --enable-languages=c,c++,fortran --enable-libstdcxx-debug --with-system-zlib --with-arch=core2
Thread model: posix
gcc version 4.4.3 (GCC)
Comment 1 Jan Kratochvil 2015-01-17 20:46:54 UTC
The reproducer works on: cf90fd9a07e8998540bf74f293d348a6653ac120
Mostly probably it has been already fixed, I have not bisected it.
Otherwise the assertion also happens for PR threads/12074.