public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/60008] New: x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage
@ 2014-01-31 13:13 peter.oberparleiter at de dot ibm.com
2014-01-31 13:44 ` [Bug gcov-profile/60008] " jakub at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: peter.oberparleiter at de dot ibm.com @ 2014-01-31 13:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60008
Bug ID: 60008
Summary: x86_64: Segmentation fault if compiled with
-fcall-saved-rdi -O2 --coverage
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: peter.oberparleiter at de dot ibm.com
Programs compiled on x86_64 with GCC and options "-fcall-saved-rdi -O2
--coverage" cause a segmentation fault.
Minimal test case:
echo "int main() { return 0; }" | gcc -xc - -o /tmp/test --coverage -O2
-fcall-saved-rdi && /tmp/test
Release:
- gcc version 4.9.0 20140116 (experimental) [master revision
c334d99:760dcd4:018db0b6e750f01880f0d601e1cf167948f55ab5] (GCC)
Configured with: configure --prefix=gcc-head-install --enable-shared
--with-system-zlib --enable-threads=posix --enable-__cxa_atexit
--enable-checking --enable-gnu-indirect-function --program-suffix=-4.9.0
--with-as=binutils/install/bin/as --with-ld=binutils/install/bin/ld
--enable-languages=c
Also found on:
- gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC)
- gcc version 4.7.2 (Debian 4.7.2-5)
- gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
Environment:
GNU/Linux
Additional information:
The cause for the segmentation fault can be found when comparing the
generated constructor functions:
gcc --coverage -O2 -fcall-saved-rdi
0000000000400c10 <_GLOBAL__I_65535_0_main>:
400c10: 57 push %rdi
400c11: 5f pop %rdi
400c12: e9 09 00 00 00 jmpq 400c20 <__gcov_init>
-> Nothing is loaded into %rdi, __gcov_init() accesses random memory
gcc --coverage -O2
0000000000400c10 <_GLOBAL__I_65535_0_main>:
400c10: 48 83 ec 08 sub $0x8,%rsp
400c14: bf 60 2a 60 00 mov $0x602a60,%edi
400c19: 48 83 c4 08 add $0x8,%rsp
400c1d: e9 0e 00 00 00 jmpq 400c30 <__gcov_init>
-> %rdi contains pointer to gcov_info structure when __gcov_init() is called
gcc --coverage -fcall-saved-rdi
0000000000400c11 <_GLOBAL__I_65535_0_main>:
400c11: 55 push %rbp
400c12: 48 89 e5 mov %rsp,%rbp
400c15: 57 push %rdi
400c16: 48 83 ec 08 sub $0x8,%rsp
400c1a: bf 80 2a 60 00 mov $0x602a80,%edi
400c1f: e8 0c 00 00 00 callq 400c30 <__gcov_init>
400c24: 48 83 c4 08 add $0x8,%rsp
400c28: 5f pop %rdi
400c29: c9 leaveq
400c2a: c3 retq
-> %rdi contains pointer to gcov_info structure when __gcov_init() is called
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug gcov-profile/60008] x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage
2014-01-31 13:13 [Bug gcov-profile/60008] New: x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage peter.oberparleiter at de dot ibm.com
@ 2014-01-31 13:44 ` jakub at gcc dot gnu.org
2014-01-31 13:51 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-31 13:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60008
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Don't do it then? %rdi is the first parameter register on x86_64, so making it
call saved is a very bad idea for many reasons.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug gcov-profile/60008] x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage
2014-01-31 13:13 [Bug gcov-profile/60008] New: x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage peter.oberparleiter at de dot ibm.com
2014-01-31 13:44 ` [Bug gcov-profile/60008] " jakub at gcc dot gnu.org
@ 2014-01-31 13:51 ` jakub at gcc dot gnu.org
2014-01-31 14:55 ` rguenth at gcc dot gnu.org
2023-01-30 17:41 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-31 13:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60008
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
E.g. -fcall-saved-rdi option is ABI changing option, so you'd need to have
everything (from libc, libgcov, libgcc, libstdc++, ...) built that way.
Furthermore, I don't think we consider this case e.g. to disallow tail call
optimization (which is generally not possible under such weird ABI).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug gcov-profile/60008] x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage
2014-01-31 13:13 [Bug gcov-profile/60008] New: x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage peter.oberparleiter at de dot ibm.com
2014-01-31 13:44 ` [Bug gcov-profile/60008] " jakub at gcc dot gnu.org
2014-01-31 13:51 ` jakub at gcc dot gnu.org
@ 2014-01-31 14:55 ` rguenth at gcc dot gnu.org
2023-01-30 17:41 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-01-31 14:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60008
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yep. Cite from invoke.texi
"It is an error to use this flag with the frame pointer or stack pointer.
Use of this flag for other registers that have fixed pervasive roles in
the machine's execution model produces disastrous results."
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug gcov-profile/60008] x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage
2014-01-31 13:13 [Bug gcov-profile/60008] New: x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage peter.oberparleiter at de dot ibm.com
` (2 preceding siblings ...)
2014-01-31 14:55 ` rguenth at gcc dot gnu.org
@ 2023-01-30 17:41 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-30 17:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60008
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |idan.horowitz at gmail dot com
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 108595 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-30 17:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 13:13 [Bug gcov-profile/60008] New: x86_64: Segmentation fault if compiled with -fcall-saved-rdi -O2 --coverage peter.oberparleiter at de dot ibm.com
2014-01-31 13:44 ` [Bug gcov-profile/60008] " jakub at gcc dot gnu.org
2014-01-31 13:51 ` jakub at gcc dot gnu.org
2014-01-31 14:55 ` rguenth at gcc dot gnu.org
2023-01-30 17:41 ` pinskia at gcc dot gnu.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).