文本编辑器应用程序中的间歇性段错误

发布于 2025-01-15 10:51:02 字数 5975 浏览 2 评论 0原文

一个小型的qt应用程序,它是一个简单的文本编辑器。我只是在 linux mint 下编译它,当我运行它时,我得到段错误,有时我得到 std::bad_alloc,首先我怀疑崩溃报告器部分

   virtual bool notify(QObject * receiver, QEvent * event) {
        //use https://github.com/AlekSi/breakpad-qt and publish first setup.
        //for setup http://www.jrsoftware.org/isdl.php
        try
        {
            return QApplication::notify(receiver,event);
        }
        catch (const std::exception &exc)
        {
            // catch anything thrown within try block that derives from std::exception
            qDebug() << exc.what();
        }
        catch(...)
        {
            QMessageBox::warning(0,
                                 tr("An unexpected error occurred"),
                                 tr("This is likely a bug."));
            QNetworkAccessManager *manager = new QNetworkAccessManager(this);
            QString winVer=(QString)QSysInfo::prettyProductName();
            manager->get(QNetworkRequest(QUrl("http://mascix.com/bigfileeditor.jsp?winVer="+winVer)));
            qDebug()<<"http://mascix.com/bigfileeditor.jsp?winVer="+winVer;
        }
        return false;
    }

我删除了它,但错误仍然出现。 strace 输出。下面你可以看到它是如何抛出错误的 segfault core dump

下面是 syslog

Mar 20 12:12:46 mint20 kernel: [40926.384026] big-file-editor[77160]: segfault at 21 ip 00007fb6ba862c0a sp 00007ffd716099b8 error 4 in libc-2.31.so[7fb6ba7d3000+178000]
Mar 20 12:12:46 mint20 kernel: [40926.384034] Code: f3 0f 1e fa 66 0f ef c0 66 0f ef c9 66 0f ef d2 66 0f ef db 48 89 f8 48 89 f9 48 81 e1 ff 0f 00 00 48 81 f9 cf 0f 00 00 77 66 <f3> 0f 6f 20 66 0f 74 e0 66 0f d7 d4 85 d2 74 04 0f bc c2 c3 48 83
Mar 20 12:12:46 mint20 systemd[1]: Started Process Core Dump (PID 77164/UID 0).
Mar 20 12:12:51 mint20 systemd-coredump[77165]: Process 77160 (big-file-editor) of user 1000 dumped core.#012#012Stack trace of thread 77160:#012#0  0x00007fb6ba862c0a __GI___strlen_sse2 (libc.so.6 + 0xb1c0a)#012#1  0x00007fb6bae2c06d _ZN16QCoreApplication9argumentsEv (libQt5Core.so.5 + 0x28a06d)#012#2  0x00007fb6b783512f n/a (libQt5XcbQpa.so.5 + 0x5012f)#012#3  0x00007fb6b7835602 _ZNK15QXcbIntegration7wmClassEv (libQt5XcbQpa.so.5 + 0x50602)#012#4  0x00007fb6b784baef _ZN10QXcbWindow6createEv (libQt5XcbQpa.so.5 + 0x66aef)#012#5  0x00007fb6b7836916 _ZNK15QXcbIntegration20createPlatformWindowEP7QWindow (libQt5XcbQpa.so.5 + 0x51916)#012#6  0x00007fb6bb3dbe15 _ZN14QWindowPrivate6createEby (libQt5Gui.so.5 + 0x12fe15)#012#7  0x00007fb6bba36808 _ZN14QWidgetPrivate6createEv (libQt5Widgets.so.5 + 0x19f808)#012#8  0x00007fb6bba36e0e _ZN7QWidget6createEybb (libQt5Widgets.so.5 + 0x19fe0e)#012#9  0x00007fb6bba43c4b _ZN14QWidgetPrivate10setVisibleEb (libQt5Widgets.so.5 + 0x1acc4b)#012#10 0x0000556c05f796ae n/a (/home/mlinux/tmp/big-file-editor/big-file-editor + 0x76ae)#012#11 0x0000556c06b1ecf0 n/a (n/a + 0x0)
Mar 20 12:12:51 mint20 systemd[1]: [email protected]: Succeeded.

gdb backtrace 输出,

(gdb) r
Starting program: /home/mlinux/tmp/big-file-editor/big-file-editor 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff2d9a700 (LWP 78778)]
qt5ct: using qt5ct plugin
[New Thread 0x7ffff216f700 (LWP 78779)]
qt5ct: D-Bus global menu: no
[New Thread 0x7ffff115b700 (LWP 78781)]
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Thread 1 "big-file-editor" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff684c859 in __GI_abort () at abort.c:79
#2  0x00007ffff6ad7911 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff6ae338c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff6ae33f7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff6ae36a9 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff6c9fe7f in qBadAlloc() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007ffff6ca3d0e in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007ffff6d6ec9c in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007ffff6ea50de in QCoreApplication::arguments() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff38ae12f in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#11 0x00007ffff38ae602 in QXcbIntegration::wmClass() const () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#12 0x00007ffff38c4aef in QXcbWindow::create() () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#13 0x00007ffff38af916 in QXcbIntegration::createPlatformWindow(QWindow*) const () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#14 0x00007ffff7454e15 in QWindowPrivate::create(bool, unsigned long long) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#15 0x00007ffff7aaf808 in QWidgetPrivate::create() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff7aafe0e in QWidget::create(unsigned long long, bool, bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff7abcc4b in QWidgetPrivate::setVisible(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x000055555555b6ae in main ()

这里是源代码 https://github.com/ozkanpakdil/big-file-editor ,易于构建,只需运行 qmakemake,我的问题是这个seg错误的原因是什么?

A small qt application, which is a simple text editor. I just compile it under linux mint and when I run it I get segfault and sometimes I get std::bad_alloc,First I suspect crash reporter part

   virtual bool notify(QObject * receiver, QEvent * event) {
        //use https://github.com/AlekSi/breakpad-qt and publish first setup.
        //for setup http://www.jrsoftware.org/isdl.php
        try
        {
            return QApplication::notify(receiver,event);
        }
        catch (const std::exception &exc)
        {
            // catch anything thrown within try block that derives from std::exception
            qDebug() << exc.what();
        }
        catch(...)
        {
            QMessageBox::warning(0,
                                 tr("An unexpected error occurred"),
                                 tr("This is likely a bug."));
            QNetworkAccessManager *manager = new QNetworkAccessManager(this);
            QString winVer=(QString)QSysInfo::prettyProductName();
            manager->get(QNetworkRequest(QUrl("http://mascix.com/bigfileeditor.jsp?winVer="+winVer)));
            qDebug()<<"http://mascix.com/bigfileeditor.jsp?winVer="+winVer;
        }
        return false;
    }

I deleted it but the error still coming. strace output. below you can see how it throws the error
segfault core dump

below syslog

Mar 20 12:12:46 mint20 kernel: [40926.384026] big-file-editor[77160]: segfault at 21 ip 00007fb6ba862c0a sp 00007ffd716099b8 error 4 in libc-2.31.so[7fb6ba7d3000+178000]
Mar 20 12:12:46 mint20 kernel: [40926.384034] Code: f3 0f 1e fa 66 0f ef c0 66 0f ef c9 66 0f ef d2 66 0f ef db 48 89 f8 48 89 f9 48 81 e1 ff 0f 00 00 48 81 f9 cf 0f 00 00 77 66 <f3> 0f 6f 20 66 0f 74 e0 66 0f d7 d4 85 d2 74 04 0f bc c2 c3 48 83
Mar 20 12:12:46 mint20 systemd[1]: Started Process Core Dump (PID 77164/UID 0).
Mar 20 12:12:51 mint20 systemd-coredump[77165]: Process 77160 (big-file-editor) of user 1000 dumped core.#012#012Stack trace of thread 77160:#012#0  0x00007fb6ba862c0a __GI___strlen_sse2 (libc.so.6 + 0xb1c0a)#012#1  0x00007fb6bae2c06d _ZN16QCoreApplication9argumentsEv (libQt5Core.so.5 + 0x28a06d)#012#2  0x00007fb6b783512f n/a (libQt5XcbQpa.so.5 + 0x5012f)#012#3  0x00007fb6b7835602 _ZNK15QXcbIntegration7wmClassEv (libQt5XcbQpa.so.5 + 0x50602)#012#4  0x00007fb6b784baef _ZN10QXcbWindow6createEv (libQt5XcbQpa.so.5 + 0x66aef)#012#5  0x00007fb6b7836916 _ZNK15QXcbIntegration20createPlatformWindowEP7QWindow (libQt5XcbQpa.so.5 + 0x51916)#012#6  0x00007fb6bb3dbe15 _ZN14QWindowPrivate6createEby (libQt5Gui.so.5 + 0x12fe15)#012#7  0x00007fb6bba36808 _ZN14QWidgetPrivate6createEv (libQt5Widgets.so.5 + 0x19f808)#012#8  0x00007fb6bba36e0e _ZN7QWidget6createEybb (libQt5Widgets.so.5 + 0x19fe0e)#012#9  0x00007fb6bba43c4b _ZN14QWidgetPrivate10setVisibleEb (libQt5Widgets.so.5 + 0x1acc4b)#012#10 0x0000556c05f796ae n/a (/home/mlinux/tmp/big-file-editor/big-file-editor + 0x76ae)#012#11 0x0000556c06b1ecf0 n/a (n/a + 0x0)
Mar 20 12:12:51 mint20 systemd[1]: [email protected]: Succeeded.

gdb backtrace output

(gdb) r
Starting program: /home/mlinux/tmp/big-file-editor/big-file-editor 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff2d9a700 (LWP 78778)]
qt5ct: using qt5ct plugin
[New Thread 0x7ffff216f700 (LWP 78779)]
qt5ct: D-Bus global menu: no
[New Thread 0x7ffff115b700 (LWP 78781)]
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Thread 1 "big-file-editor" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff684c859 in __GI_abort () at abort.c:79
#2  0x00007ffff6ad7911 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff6ae338c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff6ae33f7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff6ae36a9 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff6c9fe7f in qBadAlloc() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007ffff6ca3d0e in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007ffff6d6ec9c in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007ffff6ea50de in QCoreApplication::arguments() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff38ae12f in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#11 0x00007ffff38ae602 in QXcbIntegration::wmClass() const () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#12 0x00007ffff38c4aef in QXcbWindow::create() () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#13 0x00007ffff38af916 in QXcbIntegration::createPlatformWindow(QWindow*) const () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#14 0x00007ffff7454e15 in QWindowPrivate::create(bool, unsigned long long) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#15 0x00007ffff7aaf808 in QWidgetPrivate::create() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff7aafe0e in QWidget::create(unsigned long long, bool, bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff7abcc4b in QWidgetPrivate::setVisible(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x000055555555b6ae in main ()

here is the source code https://github.com/ozkanpakdil/big-file-editor , easy to build, just run qmake and make, my question is what is the cause of this seg fault?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文