当前位置: 首页>>技术教程>>正文


debugging – gdb:找不到新线程:通用错误

, , ,

问题描述

当我对加载与pthread链接的.so的程序运行GDB时,GDB报告错误“找不到新线程:通用错误”。

请注意,我运行的可执行文件未与pthreads链接。

有什么线索吗?


$ gdb --args lua -lluarocks.require
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/lua...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/lua -lluarocks.require
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require 'ev'
[Thread debugging using libthread_db enabled]
Cannot find new threads: generic error
(gdb) q
A debugging session is active.

    Inferior 1 [process 4986] will be killed.

Quit anyway? (y or n) y

require 'ev'上调用此函数:

http://github.com/brimworks/lua-ev/blob/master/lua_ev.c#L25-65

有关我的系统的其他信息:


$ uname -a
Linux localhost 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 04:38:19 UTC 2010 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 9.10
Release:    9.10
Codename:   karmic

最佳答案

这也适用:

LD_PRELOAD = /lib /libpthread.so.0 gdb –args ./app

次佳答案

64位Ubuntu用户应执行以下操作:

LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 gdb --args ./app

第三种答案

您还可以在主目录中创建一个包含以下文本的.gdbinit

set env LD_PRELOAD /lib/libpthread.so.0

第四种答案

当应用程序”suddenly”依赖于pthread时,GDB似乎不喜欢它。

我发现的唯一解决方法是将主机应用程序与pthreads链接。

真是可悲…

第五种答案

我发现gdb可以在运行时链接到pthreads库完成后附加到进程。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/10066.html,未经允许,请勿转载。