Qt World Summit: Submit your Presentation

MainWindow show crashed after import some static-lib in the same project.

  • Here's the problem. I created a project include some subdirs to generate static-libs and an application. After all subdirs finished, I wrote a test program to check static-libs, and it works well. But After added some UI code, it crashed at show(), I got Sementation Fault from the os. Even I didn't use any funtion from these static-libs, if I delete show(), it worked well again.
    I use gdb to run the application, it tells "reveived signal SIGSEGV, Segmentation fault. 0x00007f07b096bb81 in ??() from /usr/lib/x86_64-linux-gnu/libLLVM-9.so.1"
    I remote to server and display by X11.
    Here's the code.


    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QMainWindow>
    namespace Ui { class MainWindow; }
    class MainWindow : public QMainWindow
        MainWindow(QWidget *parent = nullptr);
        Ui::MainWindow* ui;
    #endif // MAINWINDOW_H


    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
        delete ui;


    #include "mainwindow.h"
    #include <QApplication>
    int main(int argc, char *argv[])
        QApplication a(argc, argv);
        MainWindow w;
        return a.exec();

    All these code create by default. I changed nothing
    I found a bug report:QTBUG-48875, but I it did'n work for me.

    OS: Ubuntu 20.04
    Qt: 5.12.8
    GCC: 9.3
    Qt Creator: 4.11

  • Hi - I tried your program under Windows 10, and it runs fine.

    I realize this doesn't answer your question, but have you considered updating your Qt library?

  • Hi @mzimmers , Thanks for your test.
    I have no license to update Qt library, because other guys of the company is also using the same development environment.
    I just set static-lib path in .pro file and it run crashed. I have no idea to find the reason.

  • Lifetime Qt Champion

    @KeithMaybe Did you try to run it through debugger and check the stack trace?

  • Thanks @jsulm .
    I did. I found the reason finally. Some guys operator new/delete to replace defualt new/delete, when I created an object it crashed!
    My problem solved.

  • Lifetime Qt Champion

    @KeithMaybe Please mark thread as solved

Log in to reply