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

Creating a QJSEngine still results in a segfault on sparc64 with Qt6

XMLWordPrintable

    • Linux/X11

      As already described in QTBUG-56264 for Qt 5.x, the following simple program crashes on sparc64:

      #include <QtGui/QGuiApplication>
      #include <QtQml/QJSEngine>
      
      int main(int argc, char **argv) {
          QGuiApplication app(argc, argv);
          QJSEngine engine;
          return 0;
      } 

      Full backtrace:

      (gdb) bt
      #0  QV4::StaticValue::m (this=0x0, this=<optimized out>) at ./src/qml/common/qv4staticvalue_p.h:572
      #1  QV4::InternalClass::d_unchecked (this=0x0, this=<optimized out>) at ./src/qml/jsruntime/qv4managed_p.h:189
      #2  QV4::InternalClass::d (this=0x0, this=<optimized out>) at ./src/qml/jsruntime/qv4managed_p.h:189
      #3  QV4::MemoryManager::allocateObject<QV4::Object> (this=0x10000259f50, ic=0x0) at ./src/qml/memory/qv4mm_p.h:270
      #4  QV4::MemoryManager::allocateObject<QV4::Object> (this=0x10000259f50) at ./src/qml/memory/qv4mm_p.h:280
      #5  QV4::MemoryManager::allocate<QV4::Object> (this=0x10000259f50) at ./src/qml/memory/qv4mm_p.h:313
      #6  0xfff80001011be530 in QV4::ExecutionEngine::ExecutionEngine (this=0x1000025bba0, jsEngine=<optimized out>, this=<optimized out>, jsEngine=<optimized out>) at ./src/qml/jsruntime/qv4engine.cpp:434
      #7  0xfff80001011920a4 in QJSEngine::QJSEngine (this=0x7feffbeaf28, dd=..., parent=0x0, this=<optimized out>, dd=<optimized out>, parent=<optimized out>) at ./src/qml/jsapi/qjsengine.cpp:359
      #8  0xfff8000101192184 in QJSEngine::QJSEngine (this=0x7feffbeaf28, parent=0x0, this=<optimized out>, parent=<optimized out>) at /usr/include/sparc64-linux-gnu/qt6/QtCore/qproperty.h:84
      #9  0x0000010000000b6c in main (argc=1, argv=0x7feffbeb3b8) at qt6test.cpp:6
      (gdb) 

      The cause for the crash seems to be that this is pointing to NULL.

      My suspicion is that the existing moving around of pointer bits in src/qml/common/qv4staticvalue_p.h is either incomplete on sparc64 or not used at all:

      #elif defined(Q_PROCESSOR_SPARC_64)
              // Sparc64 wants to use 52 bits for pointers.
              // Upper3 can stay where it is, bit48 moves to the top bit.
              Top1Shift   = -15,
              Upper3Shift = 0,
              Lower5Shift = 0, 

      It has been suggested that adding an additional Q_ASSERT() in line 595 might help debugging this, testing this now:

      Index: qt6-declarative-6.9.2+dfsg/src/qml/common/qv4staticvalue_p.h
      ===================================================================
      --- qt6-declarative-6.9.2+dfsg.orig/src/qml/common/qv4staticvalue_p.h
      +++ qt6-declarative-6.9.2+dfsg/src/qml/common/qv4staticvalue_p.h
      @@ -595,6 +595,7 @@ struct StaticValue
                      storePointerBits<Upper3Shift, Upper3Mask>(
                      storePointerBits<Lower5Shift, Lower5Mask>(tmp)));
       
      +        Q_ASSERT(!(_val & ManagedMask));
               QT_WARNING_POP
           }
       #elif QT_POINTER_SIZE == 4
       

      Please note that there a SPARC machines running Solaris and Linux available in the GCC Compile Farm (https://gcc.gnu.org/wiki/CompileFarm) accessible by any open source developers.

      This bug is also tracked on GitHub: https://github.com/sparclinux/issues/issues/26

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtqmlteam Qt Qml Team User
            adrian82 John Paul Adrian Glaubitz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes