线程栈溢出
gdb跟踪进程时,可以用 info frame查看当前栈桢信息,可以用 frame 、up、down 改变当前栈桢
(gdb) info frame
Stack level 0, frame at 0x9fffffffbf6af1c0: ==>当前栈地址
ip = 0xc0000000003db5f0:0 in __doprnt_main; saved ip 0xc0000000003d5990:0 ==》代码段地址
called by frame at 0x9fffffffbf6af1c0 ==》调用它的栈地址
Size of frame is 96, Size of locals is 88, Size of rotating is 2.
NAT collections saved at 0x9fffffffbf6915f8 0x9fffffffbf6917f8.
Arglist at 0x9fffffffbf6914f8, args: ==》main函数参数列表地址
Locals at 0x9fffffffbf6914f8, Previous frame's sp is 0x9fffffffbf6af1c0
在GDB时,有个变量SP,标识当前栈的地址,所以可以使用如下方法,得到整个调用上下文栈的大小
(gdb) frame 0
(gdb) set $sp_save = $sp
(gdb) # the frame # of main or __pthread_bound_body
(gdb) frame 13
(gdb) p $sp - $sp_save
可以通过以下环境变量改变线程栈默认大小:
export PTHREAD_DEFAULT_STACK_SIZE = (HP-UX)
AIXTHREAD_STKSIZE (AIX)