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)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章