I am debugging a crash and i see following behaviour -
When i attach GDB to the process and do info registers, i see the following value for esp -
esp 0xfd2475d0 0xfd2475d0
Upon doing a disassembly of code where it is crashing, I see it's storing to memory pointed-to by the stack pointer -
81c886a: c7 04 24 2c f9 8a 0c movl $0xc8af92c,(%esp)
And if i view maps file in /proc/<PID>/maps
, I see stack address range as -
fff39000-fff59000 rwxp 7ffffffde000 00:00 0 [stack]
Clearly, value of ESP 0xfd2475d0
in GDB is not in sync with the stack address in maps file.
Can this be a reason for crash. I think it should be as i am getting SIGSEGV. Also, how do I resolve this issue?
The most likely option is over allocation.
void foo() {
double too_big[6000000]; // this would be located at 0xfd......
int a; // this would be located at 0xfff3f000 ...
}