]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/breakpoints] Fix sigsegv in info prog at exec catchpoint
authorTom de Vries <tdevries@suse.de>
Tue, 3 Jul 2018 15:08:42 +0000 (17:08 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 25 Jul 2018 22:56:41 +0000 (00:56 +0200)
commit9e7f3bbbbf5a13e879a4cc3cfa958412ffac0d9d
tree1ec1b56f2d5f3784a42a4bcbaaaf0409abe11126
parent4a1b91eabbe77f4d906a0895121d76a0653c3cf3
[gdb/breakpoints] Fix sigsegv in info prog at exec catchpoint

With the test-case contained in this patch and compiled for debug we run into
a segfault with trunk gdb:
...
$ gdb catch-follow-exec -batch -ex "catch exec" \
  -ex "set follow-exec-mode new" -ex "run" -ex "info prog"
Catchpoint 1 (exec)
process xxx is executing new program: /usr/bin/ls
[New inferior 2 (process 0)]
[New process xxx]

Thread 2.1 "ls" hit Catchpoint 1 (exec'd /usr/bin/ls), in _start () from
  /lib64/ld-linux-x86-64.so.2
Segmentation fault (core dumped)
...

The patch fixes the segfault by returning an error in info_program_command
if get_last_target_status returns minus_one_ptid.

The test-case is non-standard, because the standard approach runs into
PR23368, a problem with gdb going to the background.

Build and reg-tested on x86_64-linux.

2018-07-26  Tom de Vries  <tdevries@suse.de>

PR breakpoints/23366
* infcmd.c (info_program_command): Handle ptid == minus_one_ptid.

* gdb.base/catch-follow-exec.c: New test.
* gdb.base/catch-follow-exec.exp: New file.
gdb/ChangeLog
gdb/infcmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/catch-follow-exec.c [new file with mode: 0644]
gdb/testsuite/gdb.base/catch-follow-exec.exp [new file with mode: 0644]