Discussion:
[Bug breakpoints/23302] New: SIGSEGV in gdb
rupeshpotharla at gmail dot com
2018-06-18 06:53:17 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

Bug ID: 23302
Summary: SIGSEGV in gdb
Product: gdb
Version: 8.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: breakpoints
Assignee: unassigned at sourceware dot org
Reporter: rupeshpotharla at gmail dot com
Target Milestone: ---

I am seeing the below issue in my program when running via gdb. Is this a known
issue? Am I missing something here?
Can anyone help me resolve this issue?

My test program
=============
#include<stdio.h>

int main()
{
const char foo[] = "foo";
printf("foo= %s", foo);
}


GNU gdb (GDB) 8.1
Copyright (C) 2018 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-pc-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 1...done.

(gdb) br main
Breakpoint 1 at 0x400542: file /var/1.c, line 5.
(gdb) r
Starting program: /var/1
warning: linux_ptrace_test_ret_to_nx: PC 0x33 is neither near return address
0x7ffff7ff1000 nor is the return instruction 0x445ab1!

Breakpoint 1, main () at /var/1.c:5
5 const char foo[] = "foo";
(gdb) p strlen(foo)

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000033 in ?? ()
warning: Unable to restore previously selected frame.
Couldn't write registers: Input/output error.
--
You are receiving this mail because:
You are on the CC list for the bug.
rupeshpotharla at gmail dot com
2018-06-18 06:53:45 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

rupeshpotharla at gmail dot com <rupeshpotharla at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |rupeshpotharla at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
rupeshpotharla at gmail dot com
2018-06-18 11:29:46 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

--- Comment #1 from rupeshpotharla at gmail dot com <rupeshpotharla at gmail dot com> ---
retpoline is enabled on this machine.

cat /sys/devices/system/cpu/vulnerabilities/spectre_v2
Vulnerable: Minimal generic ASM retpoline
--
You are receiving this mail because:
You are on the CC list for the bug.
simon.marchi at ericsson dot com
2018-06-18 13:15:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

Simon Marchi <simon.marchi at ericsson dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |simon.marchi at ericsson dot com

--- Comment #2 from Simon Marchi <simon.marchi at ericsson dot com> ---
Hi,

Could you try with the master branch? There has been numerous fixes related to
ifunc resolving, and it may be related to that.

Simon
--
You are receiving this mail because:
You are on the CC list for the bug.
rupeshpotharla at gmail dot com
2018-06-20 00:40:52 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

--- Comment #3 from rupeshpotharla at gmail dot com <rupeshpotharla at gmail dot com> ---
The issue is still seen even with the master branch gdb.

GNU gdb (GDB) 8.1.0.20180612-git
Copyright (C) 2018 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-pc-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 1...done.
(gdb) br main
Breakpoint 1 at 0x400541: file 1.c, line 5.
(gdb) r
Starting program: /var/1
warning: linux_ptrace_test_ret_to_nx: PC 0x33 is neither near return address
0x7ffff7ff1000 nor is the return instruction 0x444c41!

Breakpoint 1, main () at 1.c:5
5 char foo[] = {"foo"};
(gdb) p strlen(foo)

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000033 in ?? ()
warning: Unable to restore previously selected frame.
Couldn't write registers: Input/output error.
(gdb)
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-06-20 11:24:30 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

Pedro Alves <palves at redhat dot com> changed:

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

--- Comment #4 from Pedro Alves <palves at redhat dot com> ---
Post by rupeshpotharla at gmail dot com
(gdb) r
Starting program: /var/1
warning: linux_ptrace_test_ret_to_nx: PC 0x33 is neither near return address
0x7ffff7ff1000 nor is the return instruction 0x444c41!
IIRC, these early linux_ptrace_test_ret_to_nx startup checks (in
gdb/nat/linux-ptrace.c) were put in place to detect when the kernel might be
broken in such a way that inferior function calls would not work. Which seems
to be the case here.
Post by rupeshpotharla at gmail dot com
Breakpoint 1, main () at 1.c:5
5 char foo[] = {"foo"};
(gdb) p strlen(foo)
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000033 in ?? ()
This 33 looks suspectingly the same as PC 0x33 in the warning above.

The warning is pretty cryptic and I'm not sure exactly what it means off hand.
Likely using git blame to find the original patch, and/or finding the original
submission discussions would help enlighten which are the known-broken
configurations.
--
You are receiving this mail because:
You are on the CC list for the bug.
rupeshpotharla at gmail dot com
2018-08-08 05:12:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23302

rupeshpotharla at gmail dot com <rupeshpotharla at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID

--- Comment #5 from rupeshpotharla at gmail dot com <rupeshpotharla at gmail dot com> ---
The machine on which gdb is run has a bad kernel running, after fixing the
issues in kernel the issue is not seen.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...