aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qv4identifiertable
Commit message (Collapse)AuthorAgeFilesLines
* Tests: Fix warnings about comparing signed/unsignedFriedemann Kleint2019-04-081-2/+2
| | | | | | | | | | | Fix warnings like: qtestcase.h: In instantiation of 'bool QTest::qCompare(const T1&, const T2&, const char*, const char*, const char*, int) [with T1 = unsigned int; T2 = int]': tst_qquickrectangle.cpp:137:1559: required from here qtestcase.h:423:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] Change-Id: I1039e70a2933f196266512a1f5880ee409c1548b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix another bug in sweeping the identifier hash tableSimon Hausmann2018-08-301-0/+58
| | | | | | | | | | | | | | | | When an identifier overflows into the next bucket and its original spot becomes free, it is not only important to move that identifier into the now free spot. It is also necessary to shift the entries in the bucket overflowed into one entry to the left, to avoid an accidental terminator in the bucket. Such a terminator can make entire strings disappear from the hash table. That in turn may result in repeated insertion of strings that are otherwise identical, leading to internalClass lookups failing (despite the members existing) after a GC. Task-number: QTBUG-70205 Change-Id: Idf931287896a8ff730af98d36de703157e9792d3 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix invalid object property key conversionsSimon Hausmann2018-07-102-0/+313
Different property names are mapped to the same property key through a the identifier hash table. In the case of QTBUG-69280 we map a for-in loop "for (var prop in testCase)" in TestCase.qml to an internal iterator object, which signals whether it's finished or not by setting a "done" property on the iterator result object to a boolean. On the setter side, the property is specified via result->put(engine->newString("done")) and on the getter side the code uses result->get(engine->id_done()) For this to work, the newly created string has to map to the same identifier, otherwise we end up with differing property keys and wrong values. The test failure of QTBUG-69280 reproduced a scenario where two strings, "pathChanged" and "done", mapped to the same index in the hash table after a rehashing (growing), despite different string hash values. As a consequence of the hash collision they had adjacent entries in the hash table, with "pathChanged" coming first. A subsequent garbage collection run ended up with "pathChanged" being not marked and subject to removal from the identifier table. IdentifierTable::sweep() wiped the entry for "pathChanged" and lastEntry to the now free index and also remembered the exact string hash value. In the next iteration, sweep() looked at the entry for "done", which should move to the now free slot, as both strings map to the same index. However sweep() didn't do that because the comparison of string hash values failed. The fix is to compare table indices (covered by sweepFirstEntryInSameBucketWithDifferingHash) and respect bucket boundaries (covered by dontSweepAcrossBucketBoundaries). However it may happen that entries that would map to the same bucket end up after another bucket because of the insertion order. This would lead to Q_ASSERT(table[lastIdx] == nullptr); failing right after lastIdx = (lastIdx + 1) % alloc; Instead the determination of the next free slot must follow the same logic as in addEntry, by finding the first null entry. This is covered by sweepAcrossBucketBoundariesIfFirstBucketFull. Task-number: QTBUG-69280 Change-Id: I284f53418d0a75e2edb631f8bacca8c5a596e603 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>