Closed
Description
UPDATE: See the short version of the repro.
However this one might still be useful because it has to pass the test.
Repro: MinimalGCBugRepro.zip
Steps to reproduce:
npm run asbuild:incremental
thennpm test
.- Observe the expected repeating trace
123456
. npm run asbuild:minimal
thennpm test
.- Observe the unexpected traces with random numbers.
Reproduction overview:
export class SomeClass {
public someArray: StaticArray<SomeNestedClass>;
public constructor() {
this.someArray = new StaticArray<SomeNestedClass>(1);
this.someArray[0] = new SomeNestedClass();
}
public growArray(): void {
const resizedArray = new StaticArray<SomeNestedClass>(this.someArray.length * 2);
memory.copy(changetype<usize>(resizedArray), changetype<usize>(this.someArray),
offsetof<SomeNestedClass>() * this.someArray.length);
this.someArray = resizedArray;
}
public outputFirstArrayElement(): void {
trace(this.someArray[0].someField.toString());
}
}
class SomeNestedClass {
public someField: i32 = 123456;
}
const myModule = require("..");
const someClass = new myModule.SomeClass();
myModule.__pin(someClass);
someClass.growArray();
someClass.outputFirstArrayElement();
myModule.__collect();
someClass.growArray();
someClass.outputFirstArrayElement();