I recently made minor changes to previously-working code, and the program now immediately encounters a segmentation fault upon execution. In fact, it doesn't even make it to the first line in main.
Here is the beginning of the code:
int main (int argc, char* argv[])
{
fprintf(stderr, "Not even getting here!\n");
bool d;
bool v;
...
}
And the corresponding output from gdb (-g flag included upon compilation). warning: Error disabling address space randomization: Success
Program received signal SIGSEV, Segmentation fault.
0x0000000000400978 in main (argc=<error reading variable: Cannot access
memory at address 0x7fffca168f1c, argv=<error reading variable: Cannot
access memory at address 0x7fffca168f10>) at src/prog.c:35
FYI: Line 35 is just an opening brace ("{") for the main method. No actual code.
I have never encountered such an odd error before, I am baffled at how this happened. The code at the beginning was not altered at all before this error appeared, and the fact that the segmentation fault doesn't even occur anywhere near the new code is throwing me off greatly. Any code I put in main isn't being executed so I can't quite print out values to see what's going wrong.
Also, I have tried running the program with/without command-line args to see if that was the cause. It doesn't change anything.
src/prog.c
? What changes did you make? If you revert those changes does it work then? – Gothurd#include <stdio.h>
,#include <stdbool.h>
? – Whimsy<assert.h>
,<errno.h>
,<limits.h>
,<stdlib.h>
,<string.h>
and<time.h>
. It also includes a header file I've made. – Toritorie