On 19/10/2017 17:29, Miguel Munoz wrote: > 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. I cannot reproduce your issue with a trivial test case. $ cat main.c extern int foo(void); int main(void) { return foo(); } $ cat foo.c int foo(void) { return 0; } $ gcc-7 -O0 -g -fprofile-arcs -ftest-coverage foo.c main.c $ ./a.out $ echo $? 0 If you provide a reproducible test case, some people might be able to help. Regards.