public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register
@ 2010-04-04 21:08 jrgn dot keil at googlemail dot com
2010-04-04 21:16 ` [Bug target/43643] " jrgn dot keil at googlemail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: jrgn dot keil at googlemail dot com @ 2010-04-04 21:08 UTC (permalink / raw)
To: gcc-bugs
When profiling a 64bit binary compiled from the following source,
the resulting binary crashes in strdup() / strlen(),
gcc's 64bit x86 profiling code corrupts the contents of the
%rcx / %rdx register.
% /tmp/gcc4/bin/gcc --version
gcc (GCC) 4.5.0 20100401 (experimental)
% cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void
func(char *a, char *b, char *c)
{
strdup(a);
strdup(b);
strdup(c);
}
int
main(int argc, char **argv)
{
func("a", "b", "c");
exit(0);
}
% /tmp/gcc4/bin/gcc -m64 -pg -o test test.c
% file test
test: ELF 64-bit LSB executable AMD64 Version 1, dynamically linked,
not stripped
% ./test
Memory fault(coredump)
% pstack core
core 'core' of 19120: ./test
fffffd7fff23fb94 strlen () + 14
000000000040184c func () + 44
000000000040187d main () + 2f
0000000000401138 _start () + 98
gmon-sol2.c:
260 "\tmovq\t%rax,(%rsp)\n"
261 "\tmovq\t%rcx,0x08(%rsp)\n"
262 "\tmovq\t%rdx,0x10(%rsp)\n"
...
277 "\tmovq\t0x10(%rsp),%rdx\n"
278 "\tmovq\t0x08(%rsp),%rdx\n" <<<<<<<<<<<<<<
279 "\tmovq\t(%rsp),%rax\n"
Line 278 must restore to %rcx !
--
Summary: gcc -m64 -pg corrupts %rdx / %rcx register
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jrgn dot keil at googlemail dot com
GCC build triplet: i386-pc-solaris2.11
GCC host triplet: i386-pc-solaris2.11
GCC target triplet: i386-pc-solaris2.11
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
@ 2010-04-04 21:16 ` jrgn dot keil at googlemail dot com
2010-04-05 10:06 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jrgn dot keil at googlemail dot com @ 2010-04-04 21:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jrgn dot keil at googlemail dot com 2010-04-04 21:15 -------
Created an attachment (id=20306)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20306&action=view)
SUggested fix
This patch should fix the problem.
% /tmp/gcc4/bin/gcc -m64 -pg -o test test.c
% ./test
% gprof -b test gmon.out
granularity: each sample hit covers 4 byte(s) no time propagated
called/total parents
index %time self descendents called+self name index
called/total children
0.00 0.00 1/1 main [2]
[1] 0.0 0.00 0.00 1 func [1]
-----------------------------------------------
0.00 0.00 1/1 _start [16]
[2] 0.0 0.00 0.00 1 main [2]
0.00 0.00 1/1 func [1]
-----------------------------------------------
granularity: each sample hit covers 4 byte(s) no time accumulated
% cumulative self self total
time seconds seconds calls ms/call ms/call name
0.0 0.00 0.00 1 0.00 0.00 func [1]
0.0 0.00 0.00 1 0.00 0.00 main [2]
Index by function name
[1] func [2] main
Object modules
1: test
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
2010-04-04 21:16 ` [Bug target/43643] " jrgn dot keil at googlemail dot com
@ 2010-04-05 10:06 ` rguenth at gcc dot gnu dot org
2010-04-08 14:46 ` ro at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-05 10:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2010-04-05 10:06 -------
Confirmed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ro at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-04-05 10:06:06
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
2010-04-04 21:16 ` [Bug target/43643] " jrgn dot keil at googlemail dot com
2010-04-05 10:06 ` rguenth at gcc dot gnu dot org
@ 2010-04-08 14:46 ` ro at gcc dot gnu dot org
2010-04-08 14:49 ` ro at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu dot org @ 2010-04-08 14:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from ro at gcc dot gnu dot org 2010-04-08 14:46 -------
Mine.
--
ro at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ro at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Known to fail| |4.4.4 4.5.0 4.6.0
Last reconfirmed|2010-04-05 10:06:06 |2010-04-08 14:46:42
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
` (2 preceding siblings ...)
2010-04-08 14:46 ` ro at gcc dot gnu dot org
@ 2010-04-08 14:49 ` ro at gcc dot gnu dot org
2010-04-08 14:51 ` ro at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu dot org @ 2010-04-08 14:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ro at gcc dot gnu dot org 2010-04-08 14:48 -------
Subject: Bug 43643
Author: ro
Date: Thu Apr 8 14:48:46 2010
New Revision: 158130
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158130
Log:
gcc:
PR target/43643
* config/i386/gmon-sol2.c [__x86_64__]: Properly restore %rcx.
gcc/testsuite:
PR target/43643
* gcc.dg/pr43643.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/pr43643.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/gmon-sol2.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
` (3 preceding siblings ...)
2010-04-08 14:49 ` ro at gcc dot gnu dot org
@ 2010-04-08 14:51 ` ro at gcc dot gnu dot org
2010-04-08 15:10 ` ro at gcc dot gnu dot org
2010-04-08 15:12 ` ro at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu dot org @ 2010-04-08 14:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from ro at gcc dot gnu dot org 2010-04-08 14:51 -------
Subject: Bug 43643
Author: ro
Date: Thu Apr 8 14:50:56 2010
New Revision: 158131
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158131
Log:
gcc:
PR target/43643
* config/i386/gmon-sol2.c [__x86_64__]: Properly restore %rcx.
gcc/testsuite:
PR target/43643
* gcc.dg/pr43643.c: New test.
Added:
branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr43643.c
Modified:
branches/gcc-4_5-branch/gcc/ChangeLog
branches/gcc-4_5-branch/gcc/config/i386/gmon-sol2.c
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
` (4 preceding siblings ...)
2010-04-08 14:51 ` ro at gcc dot gnu dot org
@ 2010-04-08 15:10 ` ro at gcc dot gnu dot org
2010-04-08 15:12 ` ro at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu dot org @ 2010-04-08 15:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from ro at gcc dot gnu dot org 2010-04-08 15:09 -------
Subject: Bug 43643
Author: ro
Date: Thu Apr 8 15:09:17 2010
New Revision: 158133
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158133
Log:
gcc:
PR target/43643
* config/i386/gmon-sol2.c [__x86_64__]: Properly restore %rcx.
gcc/testsuite:
PR target/43643
* gcc.dg/pr43643.c: New test.
gcc:
Backport from mainline:
2010-03-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/38085
* config/i386/i386.c (x86_function_profiler)
[!NO_PROFILE_COUNTERS]: Fix typo.
* config/i386/gmon-sol2.c (_mcleanup) [__x86_64__]: Use call
instead of callq.
libgcc:
Backport from mainline:
2010-03-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/38085
* config/i386/t-sol2 ($(T)gmon.o): Use CFLAGS instead of
MULTILIB_CFLAGS.
($(T)gcrt1.o): Likewise.
($(T)crt1.o): Likewise.
($(T)crti.o): Likewise.
($(T)crtn.o): Likewise.
Added:
branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr43643.c
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/config/i386/gmon-sol2.c
branches/gcc-4_4-branch/gcc/config/i386/i386.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
branches/gcc-4_4-branch/libgcc/ChangeLog
branches/gcc-4_4-branch/libgcc/config/i386/t-sol2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/43643] gcc -m64 -pg corrupts %rdx / %rcx register
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
` (5 preceding siblings ...)
2010-04-08 15:10 ` ro at gcc dot gnu dot org
@ 2010-04-08 15:12 ` ro at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu dot org @ 2010-04-08 15:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from ro at gcc dot gnu dot org 2010-04-08 15:12 -------
Fixed for 4.4.4, 4.5.0, 4.6.0.
--
ro at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to fail|4.4.4 4.5.0 4.6.0 |
Known to work| |4.4.4 4.5.0 4.6.0
Resolution| |FIXED
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43643
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-04-08 15:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-04 21:08 [Bug target/43643] New: gcc -m64 -pg corrupts %rdx / %rcx register jrgn dot keil at googlemail dot com
2010-04-04 21:16 ` [Bug target/43643] " jrgn dot keil at googlemail dot com
2010-04-05 10:06 ` rguenth at gcc dot gnu dot org
2010-04-08 14:46 ` ro at gcc dot gnu dot org
2010-04-08 14:49 ` ro at gcc dot gnu dot org
2010-04-08 14:51 ` ro at gcc dot gnu dot org
2010-04-08 15:10 ` ro at gcc dot gnu dot org
2010-04-08 15:12 ` ro at gcc dot gnu dot org
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).