'Segmentation fault after main returns when building for coverage with gcc
I have a C program which compiles and executes fine when I build it without instrumentation flags. However, when I add instrumentation flags (-fprofile-arcs -ftest-coverage) the same program crashes with a segmentation fault after my main function returns
Has anyone seen this before when building for gcov?
I can see the following stack trace when debugging with gdb in vscode

Solution 1:[1]
This turned out to be a write beyond array bounds in my program, which was eventually causing segfault later on in the execution
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SleepyJack |
