Search code examples
c++linux64-bitqt-creatorqt5.5

permanent sigabrt at QApplication constructor when previously run ok


I am getting sigabrt right at the beginning of main() when I call:

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);//here
...

This is the backtrace

>~"#0  0x00007ffff1293cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\n"
>~"#1  0x00007ffff12970d8 in __GI_abort () at abort.c:89\n"
>~"#2  0x00007ffff213a0be in QMessageLogger::fatal(char const*, ...) const () from /opt/Qt/5.5/gcc_64/lib/libQt5Core.so.5\n"
>~"#3  0x00007fffe78f7956 in QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) () from /opt/Qt/5.5/gcc_64/lib/libQt5XcbQpa.so.5\n"
>~"#4  0x00007fffe78fb066 in QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) () from /opt/Qt/5.5/gcc_64/lib/libQt5XcbQpa.so.5\n"
>~"#5  0x00007fffe7c0e39b in ?? () from /opt/Qt/5.5/gcc_64/plugins/platforms/libqxcb.so\n"
>~"#6  0x00007ffff2e5f762 in QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) () from /opt/Qt/5.5/gcc_64/lib/libQt5Gui.so.5\n"
>~"#7  0x00007ffff2e6a9a8 in QGuiApplicationPrivate::createPlatformIntegration() () from /opt/Qt/5.5/gcc_64/lib/libQt5Gui.so.5\n"
>~"#8  0x00007ffff2e6b75d in QGuiApplicationPrivate::createEventDispatcher() () from /opt/Qt/5.5/gcc_64/lib/libQt5Gui.so.5\n"
>~"#9  0x00007ffff233da36 in QCoreApplication::init() () from /opt/Qt/5.5/gcc_64/lib/libQt5Core.so.5\n"
>~"#10 0x00007ffff233da96 in QCoreApplication::QCoreApplication(QCoreApplicationPrivate&) () from /opt/Qt/5.5/gcc_64/lib/libQt5Core.so.5\n"
>~"#11 0x00007ffff2e6d9a9 in QGuiApplication::QGuiApplication(QGuiApplicationPrivate&) () from /opt/Qt/5.5/gcc_64/lib/libQt5Gui.so.5\n"
>~"#12 0x00007ffff5ca392d in QApplication::QApplication(int&, char**, int) () from /opt/Qt/5.5/gcc_64/lib/libQt5Widgets.so.5\n"
>~"#13 0x0000000000435889 in main (argc=1, argv=0x7fffffffec48) at ..../gui/main.cpp:14\n"

Previously the code was working ok(few minutes ago), I checked the md5 of libraries and compared with another PC (with same libs, running app alright) - no differences found.

I have found some bug, but not sure if its connected.

I created new Qt project and its running ok - the main() looks the same (different includes, library dependencies).

Any ideas what shall I try next?

UPDATE:

I swear I havent changed anything, I checked with git diff - empty. This commit I am using for long time - it ran perfectly for days.

This is the message it displays:

QXcbConnection: Could not connect to display

Also - when I run from terminal ./app its running fine, when run from gdb its running fine..

but cannot run from QtCreator-gdb or just without gdb from QtCreator(Ctrl+R)..

And now its making the same error at another computer - freshly installed Qt 5.5, freshly built, also build another libraries freshly.. then I removed whole shadow dir and rebuild and the error is gone.. weird.

I did the same rm -rf shadow-dir/* and run qmake and build on my original computer - same error.


Solution

  • The message QXcbConnection: Could not connect to display means that the application failed to connect to X Display. In that case the name of the display that it was trying to connect is empty (the name should follow the message).

    The display name can be passed to the application by the environment variable DISPLAY or it can be overwritten by the application command line argument -display ' ':

    ./app-binary -display ' '
    

    Check your proper DISPLAY value in the shell:

    echo $DISPLAY
    

    Check the value of that variable in your application during run time before QApplication app(argc, argv); in Qt Creator by printing:

    qDebug() << qgetenv("DISPLAY");
    // or
    qDebug() << QProcessEnvironment::systemEnvironment().toStringList();
    

    That print should contain something like "DISPLAY=:0" (the same value as during execution from the shell).

    The Qt creator project options can overwrite system environment.