lens-vm / lens

Mozilla Public License 2.0
169 stars 5 forks source link

Wazero enumerable does not support instance reuse #71

Open AndrewSisley opened 8 months ago

AndrewSisley commented 8 months ago

Wazero enumerable does not support instance reuse within the same enumerable/pipe chain.

i.e. the below will not work:

instance, err := engine.NewInstance(module)
if err != nil {
    t.Error(err)
}

pipe := engine.Append[Value, Value](source, instance)
pipe = engine.Append[Value, Value](pipe, instance)
pipe = engine.Append[Value, Value](pipe, instance)

and will throw the following error:

runtime error: invalid memory address or nil pointer dereference (recovered by wazero)

Creating new instances for each Append call works fine, other runtimes work fine. We have a decent number of tests that fail using the wazero runtime because of this, e.g. TestWasm32PipelineFromSourceAsFullToModuleAsFullToModuleAsFull.

AndrewSisley commented 1 month ago

The way that these tests fail changed in https://github.com/lens-vm/lens/pull/88 - it fails within the Go/wazero runtime, suggesting a bug there.