Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Segmentation fault after static compilation



  • Hey there, my problem is a bit more complex, I think, but maybe someone can help me anyways. My program crashes with a segmentation fault on startup, when I compiled it statically even though it does not crash when I compile it dynamically. Is there anything I need to do extra when compiling statically?
    Here are the things I did to compile Qt statically:

    git clone git://code.qt.io/qt/qt5.git
    cd qt5
    git checkout v5.8.0
    ./init-repository --module-subset=default,-qtwebkit,-qtwebkit-examples,-qtwebengine
    ./configure -static -developer-build -opensource -nomake examples -nomake tests -confirm-license
    make -j4
    

    And I compiled my program using qmake -config release && make after adding the static Qt build to the PATH variable.
    The qmake returned the following warnings:

    Project WARNING: Plugin class name could not be determined for qwayland-egl plugin.
    Project WARNING: Plugin class name could not be determined for qwayland-generic plugin.
    Project WARNING: Plugin class name could not be determined for qwayland-xcomposite-egl plugin.
    Project WARNING: Plugin class name could not be determined for qwayland-xcomposite-glx plugin.
    

    The program compiles successfully and readelf -d QuickCurver| grep -Eo 'Shared.*'| sed 's/Shared library: [//g'| sed 's/]//g' confirms that it is linked statically (but why does it have Wayland dependencies? I run X11):

    libwayland-egl.so.1
    libXcomposite.so.1
    libwayland-client.so.0
    libwayland-cursor.so.0
    libxcb-xinerama.so.0
    libXrender.so.1
    libxcb-xkb.so.1
    libxcb-sync.so.1
    libxcb-xfixes.so.0
    libxcb-randr.so.0
    libxcb-image.so.0
    libxcb-shm.so.0
    libxcb-keysyms.so.1
    libxcb-icccm.so.4
    libxcb-shape.so.0
    libxcb-glx.so.0
    libXi.so.6
    libSM.so.6
    libICE.so.6
    libxcb-render-util.so.0
    libxcb-render.so.0
    libxkbcommon-x11.so.0
    libjasper.so.4
    libjpeg.so.8
    libmng.so.2
    libtiff.so.5
    libwebp.so.6
    libwebpdemux.so.2
    libgbm.so.1
    libdrm.so.2
    libXext.so.6
    libmtdev.so.1
    libinput.so.10
    libxkbcommon.so.0
    libudev.so.1
    libxcb.so.1
    libX11.so.6
    libX11-xcb.so.1
    libfontconfig.so.1
    libfreetype.so.6
    libts.so.0
    libEGL.so.1
    libpng16.so.16
    libharfbuzz.so.0
    libdbus-1.so.3
    libicui18n.so.58
    libicuuc.so.58
    libicudata.so.58
    libdl.so.2
    librt.so.1
    libz.so.1
    libpcre16.so.0
    libgthread-2.0.so.0
    libglib-2.0.so.0
    libGL.so.1
    libpthread.so.0
    libstdc++.so.6
    libm.so.6
    libgcc_s.so.1
    libc.so.6
    ld-linux-x86-64.so.2
    

    Now when I start it with ./Quickcurver, it immediately crashes, even though it did not when it was linked dynamically...
    stracing the system calls shows that the last system calls before the crash were the following:

    futex(0x7fafeebcb048, FUTEX_WAKE_PRIVATE, 2147483647) = 0
    getpid()                                = 11128
    # the same getpid() call repeats several times after that
    open("/dev/urandom", O_RDONLY|O_CLOEXEC) = 3
    fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
    read(3, "\203\327\236\256", 4)          = 4
    close(3)                                = 0
    --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x10} ---
    +++ killed by SIGSEGV (core dumped) +++
    [1]    11126 segmentation fault (core dumped)  strace ./QuickCurver
    

    I don't know what the chances are that someone can help me here, but I would really appreciate it if someone would. The full source code is available here: https://github.com/magnus-gross/quickcurver

    Edit: It would even help, if someone could tell me what else I can do other than using strace to further analyze the problem.


Log in to reply