From 4b312622c69b4ed7e86340d9b41e78181e5091dc Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Wed, 7 Dec 2022 17:54:27 +0000 Subject: [PATCH] fix(memory): apply gc fix from moddable --- xs/sources/xsMemory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xs/sources/xsMemory.c b/xs/sources/xsMemory.c index 28473c7c87..a9bd934db5 100644 --- a/xs/sources/xsMemory.c +++ b/xs/sources/xsMemory.c @@ -567,6 +567,7 @@ void fxGrowSlots(txMachine* the, txSize theCount) while (theCount--) { txSlot* next = aSlot + 1; aSlot->next = next; + aSlot->flag = XS_NO_FLAG; aSlot->kind = XS_UNDEFINED_KIND; #if mxPoisonSlots ASAN_POISON_MEMORY_REGION(&aSlot->value, sizeof(aSlot->value)); @@ -574,6 +575,7 @@ void fxGrowSlots(txMachine* the, txSize theCount) aSlot = next; } aSlot->next = the->freeHeap; + aSlot->flag = XS_NO_FLAG; aSlot->kind = XS_UNDEFINED_KIND; #if mxPoisonSlots ASAN_POISON_MEMORY_REGION(&aSlot->value, sizeof(aSlot->value)); @@ -839,6 +841,8 @@ void fxMarkReference(txMachine* the, txSlot* theSlot) fxCheckCStack(the); if ((aSlot = theSlot->value.array.address)) { txIndex aLength = (((txChunk*)(((txByte*)aSlot) - sizeof(txChunk)))->size) / sizeof(txSlot); + if (aLength > theSlot->value.array.length) + aLength = theSlot->value.array.length; while (aLength) { fxMarkReference(the, aSlot); aSlot++;