*** glibc 检测到*** 双重释放或损坏(fasttop):
对 QByteArray 进行清除的调用会生成以下异常:
* glibc detectors * /home/yan/FPS2/FPS2: double free or Corruption (fasttop):
0 ?? 1 ??
2 免费
3 QByteArray::clear()
4 FPSengine::getDatagrams
5 FPSengine::xmitData
6 FPSengine::getData
7 threadDatalog::run
8 ??
9 启动线程
10 克隆
11 ?? 0
这是一个 qt bug 还是与我的代码有关?我知道 QObject 不是线程安全的(QT 定义不是多个线程调用同一对象实例的同一函数),但我的函数有互斥体。此外,即使经常调用相同的函数,我也很少遇到此错误。 PS 防止这种情况的方法是 env var MALLOC_CHECK_ 0
这个 url 涉及类似的问题,一些帖子似乎暗示它是由不兼容的 glibc 版本引起的。
A call to clear on a QByteArray generates the following exception:
* glibc detected * /home/yan/FPS2/FPS2: double free or corruption (fasttop):
0 ??
1 ??
2 free
3 QByteArray::clear()
4 FPSengine::getDatagrams
5 FPSengine::xmitData
6 FPSengine::getData
7 threadDatalog::run
8 ??
9 start_thread
10 clone
11 ?? 0
is this a qt bug or could it have something to do with my code? I know QObjects arent thread safe (QT definition not multiple threads calling the same function of the same object instance)but my function has mutexes. Also I very rarely get this error even though the same function is called frequently. P.S. A way to prevent this is to env var MALLOC_CHECK_ 0
this url relates a similar problem and some posts seems to imply its caused by an incompatible version of glibc.
*** glibc detected *** perl: double free or corruption (!prev): 0x0c2b7138 ***
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它可能是许多不同的事情,包括引用函数调用返回的临时
QByteArray
,但它不太可能(IMO)是 Qt 中的错误。以下是调试的一些想法:
It could be a number of different things, including referencing a temporary
QByteArray
returned by a function call, but it's unlikely (IMO) to be a bug in Qt.Here's a few thoughts for debugging:
这是由于应用程序是多线程的,该对象属于主线程,但在另一个线程中使用,即使我在 QBytearray 上使用互斥体,使用它来执行 readDatagram 的 UDPsocket 也在主线程中......并且是的,我也需要 udpSocket 位于主线程中
this is caused by the fact the the application is multithreaded, the object belongs in the mainthread but is used in another thread, even though I used mutexes on the QBytearray the UDPsocket which uses it to do readDatagram is also in the mainthread...and yes I need that udpSocket to be in the main thread as well
我非常怀疑你是否发现了 qt 中的错误。发生该错误的原因有多种,但最重要的是您拥有对已释放内存的引用。运行调试器并尝试查看导致问题的原因。使用 gdb 和 valgrind 希望你能找到问题所在。
I highly doubt you have found a bug in qt. That error can occur for a number of reasons, but essential means you have a reference to memory that has already been freed. Run through debuggers and try and see what is causing the problem. Use gdb and valgrind and hopefully you can track down the problem.