dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.
http://dot.net
MIT License
2.91k stars 508 forks source link

Wasm: failure in gc.cpp find_first_object #8317

Closed yowl closed 4 years ago

yowl commented 4 years ago

Wasm can cause the assert assert (Align (size (o)) >= Align (min_obj_size)); in find_first_object in gc.cpp. When this happens size(o) == 0 and execution goes through the logic for searching the previous bricks. Also a clue perhaps is that o & 2 == 2

yowl commented 4 years ago

Just creating a lot of RhpNewArrayAlign8 is enough to break it.

        var mr = new MiniRandom(57);
        var keptObjects = new object[100];
        for (var i = 0; i < 1000000; i++)
        {
            var r = mr.Next();
            object o;
            o = new long[10000];
            keptObjects[r % 100] = o;
        }
yowl commented 4 years ago

Looks like I've passed the wrong size to RhpGcAlloc and RhpPublishObject, hopefully an easy fix

yowl commented 4 years ago

While the linked PR fixes the above case, this still happens when trying larger projects, e.g. starting a Uno Platform HelloWorld app