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

QDebug stack overflow due to unexpected QVariant conversion

    XMLWordPrintable

    Details

    • Technical Risk:
      Normal
    • Commits:
      b83225fcc3c6aa5655884cbf9e7391afe38b4392 (qt/qtbase/dev)

      Description

      This snippet

      #include <QtCore>
      
      class S {
      public:
          operator QVariant() const {
              return QVariant::fromValue(*this);
          }
      };
      
      Q_DECLARE_METATYPE(S)
      
      int main() {
          S s;
          qDebug() << s;
      }
      

      Has two major problems:

      1. it compiles even without a QDebug operator for S
      2. it causes a stack overflow at runtime due to an endless recursion
      #0  0x00007ffff74a925e in TestNamespace::QArrayDataPointer<char16_t>::begin (this=<error reading variable: Cannot access memory at address 0x7fffff7feff8>) at ../../include/QtCore/../../src/corelib/tools/qarraydatapointer.h:142
      #1  0x00007ffff74afb78 in void TestNamespace::QtPrivate::QCommonArrayOps<char16_t>::prepareFreeSpace<TestNamespace::QtPrivate::GrowsForwardTag, char16_t const*>(TestNamespace::QtPrivate::GrowsForwardTag, unsigned long, unsigned long, char16_t const*&, char16_t const*&)::{lambda(char16_t const* const&, char16_t const* const&)#1}::operator()(char16_t const* const&, char16_t const* const&) const (this=0x55555577aca0, first=@0x7fffff7ff130: 0x55555577b3d0 u"QVariant(", 
          last=@0x7fffff7ff128: 0x55555577b3e2 u"") at ../../include/QtCore/../../src/corelib/tools/qarraydataops.h:1228
      #2  0x00007ffff74afc4a in TestNamespace::QtPrivate::QCommonArrayOps<char16_t>::prepareFreeSpace<TestNamespace::QtPrivate::GrowsForwardTag, char16_t const*> (this=0x55555577aca0, tag=..., required=9, moveSize=0, 
          b=@0x7fffff7ff130: 0x55555577b3d0 u"QVariant(", e=@0x7fffff7ff128: 0x55555577b3e2 u"") at ../../include/QtCore/../../src/corelib/tools/qarraydataops.h:1234
      #3  0x00007ffff74ad5d7 in TestNamespace::QtPrivate::QCommonArrayOps<char16_t>::prepareSpaceForAppend<char16_t const*> (this=0x55555577aca0, b=@0x7fffff7ff130: 0x55555577b3d0 u"QVariant(", e=@0x7fffff7ff128: 0x55555577b3e2 u"", required=9)
          at ../../include/QtCore/../../src/corelib/tools/qarraydataops.h:1270
      #4  0x00007ffff74aa088 in TestNamespace::QtPrivate::QCommonArrayOps<char16_t>::copyAppend (this=0x55555577aca0, b=0x55555577b3d0 u"QVariant(", e=0x55555577b3e2 u"") at ../../include/QtCore/../../src/corelib/tools/qarraydataops.h:1371
      #5  0x00007ffff74927d1 in TestNamespace::QString::append (this=0x55555577aca0, str=0x55555577b3d0, len=9) at text/qstring.cpp:2831
      #6  0x00007ffff77cd021 in TestNamespace::QTextStreamPrivate::write (this=0x55555577acf0, data=0x55555577b3d0, len=9) at serialization/qtextstream.cpp:761
      #7  0x00007ffff77cd483 in TestNamespace::QTextStreamPrivate::putString (this=0x55555577acf0, data=0x55555577b3d0, len=9, number=false) at serialization/qtextstream.cpp:916
      #8  0x00007ffff7528aad in TestNamespace::QTextStreamPrivate::putString (this=0x55555577acf0, ch=..., number=false) at ../../include/QtCore/6.0.0/QtCore/private/../../../../../src/corelib/serialization/qtextstream_p.h:177
      #9  0x00007ffff77d249d in TestNamespace::QTextStream::operator<< (this=0x55555577ac90, string=...) at serialization/qtextstream.cpp:2516
      #10 0x00007ffff7365a9b in TestNamespace::QDebug::operator<< (this=0x7fffff7ff450, t=0x7ffff79b22e8 "QVariant(") at ../../include/QtCore/../../src/corelib/io/qdebug.h:141
      #11 0x00007ffff77766c5 in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2376
      #12 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ff580) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #13 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ff510, dbg=..., rhs=0x7fffff7ff580) at kernel/qmetatype.cpp:1709
      #14 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #15 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ff6a0) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #16 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ff630, dbg=..., rhs=0x7fffff7ff6a0) at kernel/qmetatype.cpp:1709
      #17 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #18 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ff7c0) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #19 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ff750, dbg=..., rhs=0x7fffff7ff7c0) at kernel/qmetatype.cpp:1709
      #20 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #21 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ff8e0) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #22 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ff870, dbg=..., rhs=0x7fffff7ff8e0) at kernel/qmetatype.cpp:1709
      #23 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #24 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ffa00) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #25 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ff990, dbg=..., rhs=0x7fffff7ffa00) at kernel/qmetatype.cpp:1709
      #26 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #27 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ffb20) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #28 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ffab0, dbg=..., rhs=0x7fffff7ffb20) at kernel/qmetatype.cpp:1709
      #29 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #30 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ffc40) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #31 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ffbd0, dbg=..., rhs=0x7fffff7ffc40) at kernel/qmetatype.cpp:1709
      #32 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #33 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ffd60) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #34 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ffcf0, dbg=..., rhs=0x7fffff7ffd60) at kernel/qmetatype.cpp:1709
      #35 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #36 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7ffe80) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #37 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7ffe10, dbg=..., rhs=0x7fffff7ffe80) at kernel/qmetatype.cpp:1709
      #38 0x00007ffff777673e in TestNamespace::operator<< (dbg=..., v=...) at kernel/qvariant.cpp:2379
      #39 0x00005555555564f8 in TestNamespace::QtPrivate::QDebugStreamOperatorForType<S, true>::debugStream (dbg=..., a=0x7fffff7fffa0) at ../../include/QtCore/../../src/corelib/kernel/qmetatype.h:2086
      #40 0x00007ffff7703b51 in TestNamespace::QMetaType::debugStream (this=0x7fffff7fff30, dbg=..., rhs=0x7fffff7fffa0) at kernel/qmetatype.cpp:1709
      

        Attachments

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

          Activity

            People

            Assignee:
            fabiankosmale Fabian Kosmale
            Reporter:
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes