Bug 99442 - [GCOV] No coverage with "Segmentation fault (core dumped)"
Summary: [GCOV] No coverage with "Segmentation fault (core dumped)"
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-07 08:30 UTC by Yang Wang
Modified: 2021-03-08 09:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yang Wang 2021-03-07 08:30:46 UTC
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC) 

$ cat test.c
#include <stdio.h>
char fixed_regs[0x00080000];

int main() { 
printf("PASSED\n");
return fixed_regs[0x000ff000]; 
}

$ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
PASSED
Segmentation fault (core dumped)
test.gcda:cannot open data file, assuming not executed
File 'test.c'
Lines executed:0.00% of 3
Creating 'test.c.gcov'

        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:-
        -:    0:Runs:0
        -:    1:#include <stdio.h>
        -:    2:char fixed_regs[0x00080000];
        -:    3:
    #####:    4:int main() { 
    #####:    5:printf("PASSED\n");
    #####:    6:return fixed_regs[0x000ff000]; 
        -:    7:}


Obviously, main function has been executed. However, no coverage information generated.
Comment 1 Andrew Pinski 2021-03-07 09:11:45 UTC
There is no way really to recover from a segfault in a manner that is suitable for all programs. The developer could set a sigv handler if they want to do any recovery from it. The library should not do it.
Comment 2 Martin Liška 2021-03-08 09:08:03 UTC
As Andrew explained, it's invalid. You can call __gcov_dump right before the statement that causes Segmentation fault.