From 68b9ab7b93320a975c2f20c09eddccf0fdb275b7 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 5 Nov 2020 12:43:18 +0100 Subject: V4: Prevent heap objects from getting immediately swept by GC A destruction handler can cause a new object to be allocated during garbage collection. Depending on where in the heap the object ends up, it may be found during the sweep pass. As the mark pass had no chance to mark the object, we need to set the mark bit right at allocation time in this case. Change-Id: Ie43eeb548e78bd375b001b3a6bb4ef6596f91980 Reviewed-by: Fabian Kosmale --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 96fdd012e2..985b8c7a98 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7676,7 +7676,10 @@ void tst_qqmlecmascript::onDestructionViaGC() gc(engine); QVERIFY2(mutatorResult, "We failed to re-assign the weak reference a new value during GC"); - QVERIFY2(sentinelResult, "The weak reference was not cleared properly"); + QVERIFY2(!sentinelResult, "The weak value was cleared on first GC run"); + QVERIFY2(!weakRef->isNullOrUndefined(), "The weak value was cleared on first GC run"); + gc(engine); + QVERIFY2(weakRef->isNullOrUndefined(), "The weak value was not cleared on second gc run"); } struct EventProcessor : public QObject -- cgit v1.2.3