GDB调试线程,退出时老是出现异常

yanjinbin0 2010-03-19 10:18:16
代码如下:
//多线程编程测试
#include <stdio.h>
#include<pthread.h>

//线程执行函数
void thread(void)
{
int i;

for( i = 0;i < 5; i++ ){
printf("This is a pthread.\n");
//sleep(2);
}

} //GDB调试到这里退出线程就会出现异常

int main(void)
{
pthread_t id;
int i,ret;

ret = pthread_create(&id,NULL,(void *)thread, NULL);
if ( ret!=0 ) { //不为0说明线程创建失败
printf ("Create pthread error!\n");
exit (1);
}

pthread_join(id,NULL);

return (0);
}

推出线程函数就会异常,异常表现如下:
0x009c33ae in start_thread () from /lib/tls/libpthread.so.0
(gdb)
Single stepping until exit from function start_thread,
which has no line number information.
[Thread -1208013904 (LWP 3165) exited]

然后就无法退出调试状态,CTRL+C都不管用....
也不知道是那出问题了.
...全文
471 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
谭海燕 2010-03-25
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 yanjinbin0 的回复:]
楼上兄弟,你怎么能正常啊 ,我怎么就不正常啊 ,你真是单步出线程的吗?
[/Quote]

当真,我就是这么推出的。你说的那一步我正常啊
yanjinbin0 2010-03-25
  • 打赏
  • 举报
回复
楼上兄弟,你怎么能正常啊 ,我怎么就不正常啊 ,你真是单步出线程的吗?
谭海燕 2010-03-23
  • 打赏
  • 举报
回复


不知道各位有没有具体点去执行调试他的代码。我这边调试,包括推出,完全没什么问题。

函数,线程都是正常推出。

yanjinbin0 2010-03-23
  • 打赏
  • 举报
回复
寻找高人解答下.
yanjinbin0 2010-03-22
  • 打赏
  • 举报
回复
各位,不知道,那有问题,就算让线程只执行一句printf("hello worte");要是单步一样出错,但是直接执行是就不提示错误了。.
为什么会这样????????????????
yanjinbin0 2010-03-22
  • 打赏
  • 举报
回复
求救.......
lkncjy 2010-03-22
  • 打赏
  • 举报
回复
学习,帮顶。。。。
wangqingshui531 2010-03-19
  • 打赏
  • 举报
回复
把线程设置为分离属性。
zjf30366 2010-03-19
  • 打赏
  • 举报
回复
没看出问题。
输入q,回车退出。
nevil 2010-03-19
  • 打赏
  • 举报
回复
看起来调进了线程库libpthread.so.0里的start_thread(),然后线程就执行退出了?然后gdb也没法回到主线程,好像这样就挂了?gdb没反应的具体原因看不清楚.
yanjinbin0 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wangqingshui531 的回复:]
把线程设置为分离属性。
[/Quote]

如何设置..

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧