linux下线程池,出现Segmentation fault (core dumped) 问题

GDB调试段错误,可以有效快速定位到出错该行。

1、让系统在信号中断造成的错误时产生core文件
修改core文件大小,需要su权限:
#查看core文件设置
ulimit -a
#设置core大小为无限
ulimit -c unlimited
#设置文件大小为无限
ulimit unlimited


2、编译:

******-ThinkPad-X60:~/workspace/AdvServer/src/util$ g++ -g threadpool.cpp -lpthread

3、调试:

******-ThinkPad-X60:~/workspace/AdvServer/src/util$ gdb ./a.out core

GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

Copyright (C) 2012 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. Type "show copying"

and "show warranty" for details.

This GDB was configured as "i686-linux-gnu".

For bug reporting instructions, please see:

<http://bugs.launchpad.net/gdb-linaro/>...

Reading symbols from /home/liyuanchi/workspace/AdvServer/src/util/a.out...(no debugging symbols found)...done.


warning: exec file is newer than core file.

[New LWP 7095]

[New LWP 7097]

[New LWP 7094]

[New LWP 7096]


warning: Can't read pathname for load map: Input/output error.

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Core was generated by `./a.out'.

Program terminated with signal 11, Segmentation fault.

#0 0x08048e5f in threadpool_thread(void*) ()

(gdb) backtrace

#0 0x00132416 in __kernel_vsyscall ()

#1 0x0017c1df in raise () from /lib/i386-linux-gnu/libc.so.6

#2 0x0017f825 in abort () from /lib/i386-linux-gnu/libc.so.6

#3 0x001b939a in ?? () from /lib/i386-linux-gnu/libc.so.6

#4 0x001c3ee2 in ?? () from /lib/i386-linux-gnu/libc.so.6

#5 0x08048d91 in threadpool_free (pool=0x804c008) at threadpool.cpp:194

#6 0x08048d5f in threadpool_destroy (pool=0x804c008) at threadpool.cpp:182

#7 0x08048f05 in main () at threadpool.cpp:229

(gdb)


你可能感兴趣的:(gdb调试技巧)