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

Indexing arrays by two-digit strings (a["10"], a["11"], …) does not work on s390x

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.0
    • None
    • Ubuntu 17.10 (artful) s390x

    Description

      Today Christian Ehrhardt from Canonical and I have been debugging a very strange bug that happens only on Ubuntu s390x.

      The initial problem was that the QtMultimedia tests were hanging after the following warning:

      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(-1.0 from linear to linear)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(0.0 from linear to linear)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(0.5 from linear to linear)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(1.0 from linear to linear)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(-1.0 from linear to cubic)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(0.0 from linear to cubic)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(0.33 from linear to cubic)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(0.5 from linear to cubic)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(0.72 from linear to cubic)
      PASS   : QDeclarativeMultimediaGlobal::test_convertVolume(1.0 from linear to cubic)
      QWARN  : QDeclarativeMultimediaGlobal::test_convertVolume() file:///usr/lib/s390x-linux-gnu/qt5/qml/QtTest/TestCase.qml:1781: TypeError: Cannot read property 'tag' of undefined
      

      No matter what the ordering of tests in test_convertVolume_data() was, the 0th to 9th always passed, but for the 10th test the warning was printed, after which it hanged.

      After some debugging, Christian figured out that when iterating any array with the for (var i in array) construct, array[i] will be always undefined for i ≥ 10. However iterating the array with for (i = 0; i < array.length; ++i) works fine. So applying this change to qtdeclarative’s TestCase.qml fixed the qtmultimedia warning and hang:

      @@ -1775,7 +1775,7 @@ Item {
                           var table = qtest_testCaseResult
                           var haveData = false
                           qtest_results.initTestTable()
      -                    for (var index in table) {
      +                    for (var index = 0; index < table.length; index++) {
                               haveData = true
                               var row = table[index]
                               if (!row.tag)
      

      Some more testing showed that when iterating the first way, index is a string, and for the second way, it is an integer. So the root issue is probably that indexing the array by strings fails when the string is two or more characters.

      For some unknown reason, this bug does not occur on Debian s390x, but occurs only on Ubuntu. One notable difference between Debian and Ubuntu is use of -Wl,-Bsymbolic-functions link flag, but there may be other differences. Because s390x is the only big endian architecture in Ubuntu, I cannot tell whether it is s390x specific or a problem with big endian architectures in general.

      Note: to test any QML code on big endian, one needs commit 4199572d64d46bfa applied — otherwise everything just crashes.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            mandriver Dmitry Shachnev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes