How does the gcc option -fstack-check exactly work?

gcc, stack

Solution

After checked the assembly program. I think -fstack-check, will add code write 0 to an offset of the stack pointer, so to test if the program visit a violation address, the program went crash if it does. e.g. mov $0x0,-0x928(%esp)

Problem

My program crashed when I added the option -fstack-check and -fstack-protector. __stack_chk_fail is called in the back trace. So how could I know where the problem is ? What does -fstack-check really check ? The information about gcc seems too huge to find out the answer.

Original source

Related problems