public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "prumpf at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug threads/16778] New: amd64 displacement code oddity; segfault Date: Sat, 29 Mar 2014 19:00:00 -0000 [thread overview] Message-ID: <bug-16778-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=16778 Bug ID: 16778 Summary: amd64 displacement code oddity; segfault Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: threads Assignee: unassigned at sourceware dot org Reporter: prumpf at gmail dot com Created attachment 7502 --> https://sourceware.org/bugzilla/attachment.cgi?id=7502&action=edit diff (I'm not sure I've categorized this correctly) This is a bug report for gdb 7.6.2, built from yesterday's git repository sources, on amd64 hardware (a Debian system). It affects non-stop mode only. The displacement code which is activated in non-stop mode appears to truncate return addresses on the stack, resulting in strange segfaults when debugging threaded code. I ran into the issue in another context but I believe I have a test case. It's possible I'm merely confused. I'm having a very hard time making sense of this bit of code in amd64-tdep.c; retaddr = read_memory_unsigned_integer (rsp, retaddr_len, byte_order); retaddr = (retaddr - insn_offset) & 0xffffffffUL; write_memory_unsigned_integer (rsp, retaddr_len, byte_order, retaddr); The second line, in particular. It seems to me that it would break debugging shared libraries, which do not reside in the low 4 GB of virtual memory (on my machine). Indeed, my experiments seem to confirm that something is wrong: --------- % gcc -fPIC -g -shared -o libfail.so gdb-fail-library.c gcc -fPIC -g -shared -o libfail.so gdb-fail-library.c % gcc -g gdb-fail.c -L . -lfail gcc -g gdb-fail.c -L . -lfail % ./gdb-build/gdb/gdb a.out ./gdb-build/gdb/gdb a.out GNU gdb (GDB) 7.7.50.20140328-cvs Copyright (C) 2014 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". 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 a.out...done. (gdb) set non-stop on set non-stop on (gdb) b f b f Breakpoint 1 at 0x400540 (gdb) r r Starting program: .../a.out warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? Breakpoint 1, f () at gdb-fail-library.c:6 6 return g(); (gdb) stepi stepi 0x00007ffff7bdc580 in g@plt () from .../libfail.so (gdb) bt bt #0 0x00007ffff7bdc580 in g@plt () from .../libfail.so #1 0x00000000f7bdc699 in ?? () #2 0x00007fffffffea00 in ?? () #3 0x0000000000400666 in main () at gdb-fail.c:5 Backtrace stopped: frame did not save the PC --------- Note the truncated return address on the stack. And indeed: ---------- (gdb) c c Continuing. Program received signal SIGSEGV, Segmentation fault. 0x00000000f7bdc699 in ?? () ---------- The test program/library is fairly minimal: --------- int g(void) { return 0; } int f(void) { return g(); } --------- extern int f(void); int main(void) { f(); return 0; } --------- I very much suspect there is a good reason the original code did not omit the &0xffffffffUL part, but removing it appears to work in this one test case. I've attached a patch that does that. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2014-03-29 19:00 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-03-29 19:00 prumpf at gmail dot com [this message] 2014-03-29 19:01 ` [Bug threads/16778] " prumpf at gmail dot com 2014-03-29 19:02 ` prumpf at gmail dot com 2014-03-29 19:08 ` prumpf at gmail dot com 2014-03-29 23:26 ` dje at google dot com 2014-04-01 9:08 ` prumpf at gmail dot com 2024-01-13 13:15 ` ssbssa at sourceware dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-16778-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).