多线程的坑

本文记录了在ROS环境下运行yuyilocation模块时遇到的多种错误,包括段错误、freeglut错误及xcb相关错误。文章指出在引入多线程(使用pthread_create)后,主函数需紧跟循环语句如while(1),以避免出现异常。并提供了多线程编程技巧及调试建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

robot@robot:~/ck_test1_wjw $ rosrun yuyi location
Segmentation fault (core dumped)
robot@robot:~/ck_test1_wjw $ rosrun yuyi location
freeglut  ERROR:  Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow
robot@robot:~/ck_test1_wjw $ rosrun yuyi location
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
location: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted (core dumped)
robot@robot:~/ck_test1_wjw $ rosrun yuyi location
[xcb] Extra reply data still left in queue
[xcb] This is most likely caused by a broken X extension library
[xcb] Aborting, sorry about that.
location: ../../src/xcb_io.c:576: _XReply: Assertion `!xcb_xlib_extra_reply_data_left' failed.
Aborted (core dumped)
robot@robot:~/ck_test1_wjw $ rosrun yuyi location
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
location: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted (core dumped)
robot@robot:~/ck_test1_wjw $ rosrun yuyi location
^[[ASegmentation fault (core dumped)

加入多线程之后,也就是pthread_create,主函数的后面一定要跟一些循环语句。。。while(1)什么的。否则会出错。

https://blog.youkuaiyun.com/weixin_41931548/article/details/80802340多线程的讲解,加MFC的,挺不错

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr.Naruto

你的鼓励是我的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值