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

QMap<Key,T> + T::operator& = bad things

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.6.3, 4.8.3
    • None
    • Linux
    • 5cb0368516abd293daf67711a36bbacc99422e9a

    Description

      QMap in its current form cannot be reliably used with any class (as either key or value) that implements operator&. This is because node_create (but also operator->) takes the address of a QMap::Node member when invoking placement operator new, which results in

      {T|Key}::operator& being invoked on an uninitialized {T|Key}

      , when invoking the class operator& is clearly not desired.

      I discovered this with QMap, but other containers are likely affected. The fix is to use something like boost addressof instead of '&'.

      The attached program /may/ demonstrate the problem; on my system I get a glibc-detected memory corruption (and the program hangs), but no errors from valgrind. (In my real program, however, the data access pattern causes the QMap storage to be filled with old data that causes a SEGV; this example is unfortunately not sophisticated enough to cause that.)

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            matthew.woehlke Matthew Woehlke
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes