bug report: Jump to the invalid address stated on the next line at 0x0: ???

时间:2021-07-22 22:14:11

gdb或者vlagrind报告:

==14569== Jump to the invalid address stated on the next line
==14569== at 0x0: ???
==14569== Address 0x0 is not stack'd, malloc'd or (recently) free'd

错误原因:函数通过jmp,call,ret等指令跳转到0x00,错误可能出现的范围

1.函数缓冲区溢出覆盖了返回地址,然后又调用了return,例如

#include <memory.h>

void main(void)
{
int i;
memset(&i,0,20);
return;
}

2.函数使用了未初始化的函数指针,例如

void (*func)(void);

void main(void)
{
func();
}