多线程 exit()调用析构函数引发的死锁 附加:gdb调试

news/2024/5/20 12:10:21 标签: 死锁, 多线程, exit与析构函数, gdb调试

GlobalObject
exit()
调试代码:

(gdb) l
20	    {
21	        printf("GlobalObject:~GlobalObject() \n");
22	        MutexLockGuard lock(mutex_);
23	        printf("GlobalObject:~GlobalObject() cleanning\n");
24	    }
25	
26	private:
27	    MutexLock mutex_;
28	};
29	
(gdb) l
30	GlobalObject g_obj;
31	
32	int main()
33	{
34	    g_obj.doit();
35	}(gdb) 
Line number 36 out of range; exit.cpp has 35 lines.
(gdb) b main
Breakpoint 1 at 0x98c: file exit.cpp, line 34.
(gdb) r
Starting program: /root/study/chapter-4/exit 

Breakpoint 1, main () at exit.cpp:34
34	    g_obj.doit();
(gdb) b 21
Breakpoint 2 at 0x555555554bb3: file exit.cpp, line 21.
(gdb) b 23
Breakpoint 3 at 0x555555554bd2: file exit.cpp, line 23.
(gdb) l
29	
30	GlobalObject g_obj;
31	
32	int main()
33	{
34	    g_obj.doit();
35	}(gdb) 
Line number 36 out of range; exit.cpp has 35 lines.
(gdb) s
GlobalObject::doit (this=0x555555756040 <g_obj>) at exit.cpp:13
13	    void doit()
(gdb) s
15	        MutexLockGuard lock(mutex_);
(gdb) p mutex
No symbol "mutex" in current context.
(gdb) p mutex_
$1 = {<noncopyable> = {<No data fields>}, mutex_ = {__data = {__lock = 0, __count = 0, __owner = 0, __
    __size = '\000' <repeats 39 times>, __align = 0}, holder_ = 0}
(gdb) s
MutexLockGuard::MutexLockGuard (this=0x7fffffffe4a0, mutex=...) at mutex.h:41
41	    : mutex_(mutex)
(gdb) s
noncopyable::noncopyable (this=0x7fffffffe4a0) at noncopyable.h:6
6	    noncopyable() {}
(gdb) s
MutexLockGuard::MutexLockGuard (this=0x7fffffffe4a0, mutex=...) at mutex.h:42
42	    { mutex_.lock(); }
(gdb) s
MutexLock::lock (this=0x555555756040 <g_obj>) at mutex.h:22
22	        pthread_mutex_lock(&mutex_);
(gdb) s
pthread_mutex_lock (mutex=0x555555756040 <g_obj>) at forward.c:192
192	forward.c: No such file or directory.
(gdb) s
MutexLock::lock (this=0x555555756040 <g_obj>) at mutex.h:24
24	    }
(gdb) s
GlobalObject::doit (this=0x555555756040 <g_obj>) at exit.cpp:16
16	        someFunctionMayCallExit();
(gdb) s
someFunctionMayCallExit () at exit.cpp:7
7	    exit(1);
(gdb) p errno
$2 = 0
(gdb) s
__GI_exit (status=1) at exit.c:139
139	exit.c: No such file or directory.
(gdb) p errno
$3 = 0
(gdb) s
138	in exit.c
(gdb) s
139	in exit.c
(gdb) bt
#0  __GI_exit (status=1) at exit.c:139
#1  0x0000555555554988 in someFunctionMayCallExit () at exit.cpp:7
#2  0x0000555555554b75 in GlobalObject::doit (this=0x555555756040 <g_obj>) at exit.cpp:16
#3  0x0000555555554998 in main () at exit.cpp:34
(gdb) p mutex_
No symbol "mutex_" in current context.
(gdb) s
__run_exit_handlers (status=1, listp=0x7ffff7a46718 <__exit_funcs>, run_list_atexit=run_list_atexit@en
40	in exit.c
(gdb) p errno
$4 = 0
(gdb) p AccountA_mutex
No symbol "AccountA_mutex" in current context.
(gdb) info threads
  Id   Target Id         Frame 
* 1    process 1039 "exit" __run_exit_handlers (status=1, listp=0x7ffff7a46718 <__exit_funcs>, 
    run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:40
(gdb) pstack 1039
Undefined command: "pstack".  Try "help".
(gdb) quit


http://www.niftyadmin.cn/n/726717.html

相关文章

生成索引脚本

create proc p_helpindex tbname sysname ,type char(1) 1 as --生成索引信息及索引创建脚本 --author : perfectaction --tbname 表名&#xff0c;空返回所有表索引 --type 是否显示聚集索引,1显示聚集索引,2不显示聚集索引 --调用&#xff1a;p_helpindex dbo.customer…

Windows 下 sbcl or slime 搭建lisp开发环境

Apr 08, 2011 emacs, lisp, sbcl, slime 及 windows 今天有人问&#xff0c;windows下如何配置Slimesbcl 开发环境&#xff0c;以前配置过&#xff0c;但现在没用&#xff0c;就重新配置了下。大概配置步骤。 先下载Emacs 的windows版本&#xff0c;下载地址自己找。SBCL的下载…

软件项目管理总结

软件项目管理 软件项目是艺术也是工程艺术 软件项目管理的生命周期 启动、计划、执行、控制、结束 项目管理是怎么回事&#xff1f; 什么是项目&#xff1f; 项目管理 项目管理的起源 项目管理的本质理解 任务、进度、成本、质量的平衡 软件项目管理的对象-3P peopl…

strstr 不错的技巧

strstr 不错的技巧 $aa "我爸爸是李刚" strstr(($aa,李刚)); 转载于:https://www.cnblogs.com/wangzong/archive/2011/06/16/2082997.html

测试管理

第一章 软件测试、缺陷、质量等概念&#xff0c;产品/使用质量模型及其属性&#xff0c;软件测试的价值与定义、辩证地理解测试&#xff08;狭义/广义、静态/动态等&#xff09;&#xff0c;软件测试的层次、类型、软件测试和SQA的区别和联系 第二章 静态测试&#xff08;评…

浅谈Linux内存管理

浅谈Linux内存管理lecury​1. 扫盲篇1.1 操作系统存储层次常见的计算机存储层次如下&#xff1a;寄存器&#xff1a;CPU提供的&#xff0c;读写ns级别&#xff0c;容量字节级别。CPU缓存&#xff1a;CPU和CPU间的缓存&#xff0c;读写10ns级别&#xff0c;容量较大一些&#xf…

如何正确地在XHTML文档中使用JavaScript和CSS

在越来越多的网站中&#xff0c;XHTML的使用正以很快的速度替代HTML4&#xff0c;但是&#xff0c;目前一些主流浏览器对XHTML的支持还不是很好&#xff0c;加上一些网页制作者对XHTML和HTML4之间的差异理解不够&#xff0c;使得XHTML在WEB发展上进程变得缓慢。 XHTML是XML而不…