I am trying to execute C ++ code on my Debian machine. I use the GCC compiler. It compiles my code without errors and warnings, but when I start it, I get an error Segmentation fault . Googled this problem and found something. They offer to perform debugging of the program through GDB. What I've done:

gcc /путь_к_программе -g gdb ./a.out run backtrace 

As a result, the debugger indicated to me that there was an error in this section of the code:

 while(fgets(strLine, 256, list_fd) != NULL) { ParseResolverLine(strLine, iLine); iLine++; } 

Issuance of the debugger itself:

 #0 _IO_fgets (buf=0x607010 "", n=256, fp=0x0) at iofgets.c:50 #1 0x000000000040185f in main (argc=6, argv=0x7fffffffec68) 

Actually, I don’t understand exactly where the segmentation of memory appears in the indicated part of the code.

    1 answer 1

    Your list_fd is NULL ( fp=0x0 in the debugger). Check that the file has opened, if something goes wrong fopen() returns NULL .