Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

Fixing bugs via lateral thinking

Lessons learned by digging into obscure QML bugs


import QtQuick 2.0

QtObject {
    Component.onCompleted: {
        console.log("240000000000" == "3776798720");
    }
}

     QJSEngine engine;
     QJSValue value("foo");

     QJSValue obj = engine.newObject();
     obj.setProperty("240000000000", value);

     QJSValueIterator it(obj);
     while (it.hasNext()) {
         it.next();
         qDebug() << it.name() << it.value().toString();
     }

240000000000 == 0x37E11D6000
3776798720   ==   0xE11D6000

238609294221 == 0x378E38E38D   // biggest working before the problematic range
238609294222 == 0x378E38E38E   // smallest not working
249108103166 == 0x39FFFFFFFE   // biggest not working
249108103166 == 0x39FFFFFFFF   // smallest working after the problematic range

Visualization of C++ function call traces into Chromium.


     ScopedString s(scope, engine->newString(name));
     uint idx = s->asArrayIndex();
     if (idx < UINT_MAX) {
         setProperty(idx, value);
         return;
     }
     s->makeIdentifier(scope.engine);
     QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value));
     o->put(s, v);

     uint asArrayIndex() const {
         if (subtype() == Heap::String::StringType_Unknown)
             d()->createHashValue();
         Q_ASSERT(!d()->largestSubLength);
         if (subtype() == Heap::String::StringType_ArrayIndex)
             return d()->stringHash;
         return UINT_MAX;
      }

         uint n = i*10 + x;
         if (n < i)
             // overflow
             return UINT_MAX;

About KDAB


GiuseppeD'Angelo

Giuseppe D’Angelo

Senior Software Engineer

Learn Modern C++

Learn more