Open mallochine opened 3 years ago
hello, ping, any chance this is going to get looked at soon?
I was going to try to patch the library, but while trying to do it I discovered the way to fix this is to tell the perlin network VM to grow the memory with a new VMConfig:
_, err = exec.NewVirtualMachine(bytes, exec.VMConfig{
MaxMemoryPages: 4,
DefaultMemoryPages: 1,
}, new(exec.NopResolver), nil)
It was erroring out because of this line: copy(memory[offset:], e.Data)
where len(memory)
was 0. It was zero due to initialLimit
being 0 (initialLimit := int(m.Base.Memory.Entries[0].Limits.Initial)
)
So the fix for this issue then is to make the perlin-network/life more user friendly by doing this:
if initialLimit == 0 {
panic("Please configure MaxMemoryPages and DefaultMemoryPages to be more than 0 so that PerlinNetwork Life can grow the Webassembly VM memory")
}
Can somebody submit a pull request for this? I'm busy right now with other stuff, thanks!
EDIT: please see my last comment on this issue for how I managed to fix the error I reported below.
FYI I raised the same issue with
gasm
(https://github.com/mathetake/gasm/issues/18). They have the same problem. I copy-pasted a lot of it since a lot of it is the same.Here is a repro test case for ya:
And I've attached the bls.wasm file as a bls.txt since Github won't let me upload a filetype wasm.
bls.txt
There are other two ways of getting the wasm:
Network
tab in Chrome Developer Console, then download the file in data:application/octet-stream.This is the error message I get