Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113315

Segmentation fault in a VirtualBox Linux guest with -march=native

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 5.15.14, 6.2.9, 6.5.2, 6.6.0
    • 5.15.9
    • GUI: Painting
    • None
    • Gentoo Linux on VirtualBox with -march=native
    • Linux/X11
    • 178c123a6 (dev), bfea141e5 (6.5), 5633df6ff (tqtc/lts-6.2), c2a2aac02 (tqtc/lts-5.15)

    Description

      I was unable to get issue QTBUG-105740 reopened, so I'm making a new one. Here's the comment I made:

      A friend of mine also ran into this issue on Gentoo in VirtualBox. This happened because they used -march=native, and the CPUID in VirtualBox claims AVX2 support but not FMA or F16C support (see attached cpuid.txt).

      I was able to reproduce this outside of VirtualBox by simply adding -mavx2 -mno-fma to CFLAGS/CXXFLAGS when building Qt, and then using setting the environment variable QT_NO_CPU_FEATURE='fma' at runtime. Basically any graphical Qt app will hit this, I used qt5ct.

      The problem is that in qInitDrawhelperFunctions, the SSE2 fallback for qt_memfill32 is disabled when AVX2 is available at compile-time, but the AVX2 version is only enabled if `qCpuHasFeature(ArchHaswell)`, which requires AVX2 but also FMA, F16C, and other features to be either enabled at compile-time or to be set in cpuid at runtime. When using -march=native inside of VirtualBox, FMA and F16C are neither compiled in nor detected at runtime, so the AVX2 version is not used, and with no fallback it stays at its initial value of NULL.

      I think the simple fix is to make the SSE2 fallback available even if AVX2 is enabled at compile-time - remove `#ifndef __AVX2__`.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-113315
          # Subject Branch Project Status CR V

          Activity

            People

              allan.jensen Allan Sandfeld Jensen
              cebtenzzre Cebtenzzre X
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes