Gcc 为什么gcov会导致程序崩溃?
我正在使用gcov在Linux上测试我的程序add-fprofile arcs-ftest覆盖率,但该程序在启动后将崩溃:Gcc 为什么gcov会导致程序崩溃?,gcc,gcov,Gcc,Gcov,我正在使用gcov在Linux上测试我的程序add-fprofile arcs-ftest覆盖率,但该程序在启动后将崩溃: (gdb) bt #0 0x00000034e433386f in __strlen_sse42 () from /lib64/libc.so.6 #1 0x000000000053c57a in __gcov_init () #2 0x000000000053c4b9 in _GLOBAL__I_65535_0_g_st_rerun_cmd_param ()
(gdb) bt
#0 0x00000034e433386f in __strlen_sse42 () from /lib64/libc.so.6
#1 0x000000000053c57a in __gcov_init ()
#2 0x000000000053c4b9 in _GLOBAL__I_65535_0_g_st_rerun_cmd_param ()
at source/rerun/aicent_ara_rerun.c:963
#3 0x000000000053dc26 in __do_global_ctors_aux ()
#4 0x0000000000403743 in _init ()
#5 0x00007fff6d6b3ce8 in ?? ()
#6 0x000000000053db55 in __libc_csu_init ()
#7 0x00000034e421ecb0 in __libc_start_main () from /lib64/libc.so.6
#8 0x0000000000404449 in _start ()
从uu gcov_init source
我可以看到根本原因是信息->文件名在反汇编代码后无效,地址是0x57c4ac00000000,确实无效
我不知道如何分析这个错误,有人能提供一些线索吗?非常感谢
另外,我的Linux环境:
[root@localhost rel_1_3_3_20140902]# uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
gcc版本:
[root@localhost rel_1_3_3_20140902]# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
此问题的根本原因是在64位Linux上使用-fpack struct=4编译选项。有关详细信息,我们可以参考
[root@localhost rel_1_3_3_20140902]# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)