user180574
user180574

Reputation: 6084

how to debug "*** buffer overflow detected ***: program_name terminated" along with _FORTIFY_SOURCE=2

My program crashes with the message "*** buffer overflow detected ***: program_name terminated", and I suspect it may be related to the compiler option "_FORTIFY_SOURCE=2" that I use (source: difference between gcc -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2).

In general, how to find the program point that generates such error?

Upvotes: -1

Views: 792

Answers (1)

Employed Russian
Employed Russian

Reputation: 213646

In general, how to find the program point that generates such error?

For this particular error, running the program under debugger will immediately tell you where the error happened.

I can try it, my feeling is that ...

You should try it and your feeling is wrong.

P.S. Building your program with -fsanitize=address (if your compilation and runtime environment supports it) and running it may produce a more informative error message.

Upvotes: 2

Related Questions