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

Comparing of memory chunks with garbage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.7.4
    • 4.7.1
    • None
    • All major platforms supported by Qt.
    • 95aa4e4f9b82c3652ffc93310b190db869d491df

    Description

      Declarative module creates dynamic meta object data in heap, allocating chunk of memory and casting it to appropriate class with reinterpret_cast. Because such chunks never being cleaned (for instance with memset) and class members are aligned - chunk of memory will still contain uninitialized bytes. This leads to potential undefined behavior when comparing such chunks with memcmp in hope that they will be equal. But they will not if class instance has been copied using copy constructor or operator=.

      Valgrind triggers several "jump on uninitialized value" errors.
      At least if uninitialized memory chunks are ok exactly this cases - they should be cleaned anyway to help to locate real errors.

      Example of such comparing:
      In qdeclarativecompileddata.cpp:
      int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data)

      Hot to fix:
      In qmetaobjectbuilder.cpp:
      Add memset(buf, 0, size).
      Here: QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
      And here: QMetaObject *QMetaObjectBuilder::toMetaObject() const

      Attachments

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

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            dendy Daniel Levin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes