4章

#

4章_第1张图片

2

通过gdb调试分析,程序在无线递归调用时,栈空间地址不断向上面写入数据,最终会导致段错误。!

[------------------------------------stack-------------------------------------]
0000| 0xffffcf7c --> 0x804840a (<foo+11>:   leave)
0004| 0xffffcf80 --> 0xf7ffd938 --> 0x0 
0008| 0xffffcf84 --> 0x0 
0012| 0xffffcf88 --> 0xffffcf98 --> 0xffffcfa8 --> 0xffffcfb8 --> 0xffffcfc8 --> 0xffffcfd8 --> 0xffffcfe8 --> 0x0 
0016| 0xffffcf8c --> 0x804840a (<foo+11>:   leave)
0020| 0xffffcf90 --> 0xffffffff 
0024| 0xffffcf94 --> 0xffffcfbe --> 0x10804 
0028| 0xffffcf98 --> 0xffffcfa8 --> 0xffffcfb8 --> 0xffffcfc8 --> 0xffffcfd8 --> 0xffffcfe8 --> 0x0 
[------------------------------------------------------------------------------]

执行几次之后

[------------------------------------stack-------------------------------------]
0000| 0xffffcf78 --> 0xffffcf88 --> 0xffffcf98 --> 0xffffcfa8 --> 0xffffcfb8 --> 0xffffcfc8 --> 0xffffcfd8 --> 0xffffcfe8 --> 0x0 
0004| 0xffffcf7c --> 0x804840a (<foo+11>:   leave)
0008| 0xffffcf80 --> 0xf7ffd938 --> 0x0 
0012| 0xffffcf84 --> 0x0 
0016| 0xffffcf88 --> 0xffffcf98 --> 0xffffcfa8 --> 0xffffcfb8 --> 0xffffcfc8 --> 0xffffcfd8 --> 0xffffcfe8 --> 0x0 
0020| 0xffffcf8c --> 0x804840a (<foo+11>:   leave)
0024| 0xffffcf90 --> 0xffffffff 
0028| 0xffffcf94 --> 0xffffcfbe --> 0x10804 
[------------------------------------------------------------------------------]

你可能感兴趣的:(linux内核编程,调试)