Segmentation fault at gcov exit

Miguel Munoz miguiman@gmail.com
Thu Oct 19 15:29:00 GMT 2017


Hi,

I’m running a C program using gcov and I get a segmentation fault when
gcov is dumping the results at the end of the execution. The program
exits correctly when compiled without coverage.

The problem appears when one of the files contains a function call to
an extern function defined in another file. If I comment this call, no
SIGSEGV occurs. If I leave the call and compile without coverage, the
SIGSEGV also disappears.

I’m compiling with the options: -O0 -g -fprofile-arcs -ftest-coverage.
Adding -Wall -Wextra doesn’t show anything suspicious.

Could you help me debugging this error? The backtrace doesn’t give me
any source file or line number inside the gcov code, and I don’t know
how to investigate the problem further.

This is the backtrace from gdb:

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106         ../sysdeps/x86_64/strlen.S: No such file or directory.
(gdb) bt
#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x000000000040df67 in gcov_do_dump ()
#2  0x000000000040f3a2 in gcov_exit ()
#3  0x00007ffff761aff8 in __run_exit_handlers (status=0,
listp=0x7ffff79a55f8 <__exit_funcs>,
run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#4  0x00007ffff761b045 in __GI_exit (status=<optimized out>) at exit.c:104
#5  0x00007ffff7601837 in __libc_start_main (main=0x404813 <main>,
argc=1, argv=0x7fffffffd388, init=<optimized out>, fini=<optimized
out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd378)
    at ../csu/libc-start.c:325
#6  0x0000000000404309 in _start ()

I’m using Ubuntu 16.04 64-bit, and I’ve tried with the GCC versions
5.4.1, 6.4.0 and 7.2.0, always with the same result.

Thanks a lot,
Miguel



More information about the Gcc-help mailing list