-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
This could be more relevant for https://github.com/dylibso/chicory, but creating an issue here to start.
I want to run a JSON example from the go-pdk. I can compile the example with tinygo and run it with the extism CLI:
extism call plugin.wasm add --input='{"a": 20, "b": 21}' --wasi
{"sum":41}
However, I'm getting com.dylibso.chicory.runtime.TrapException: Trapped on unreachable instruction when trying to run it with chicory-sdk. Debugging the interpreter steps shows me that it goes to panic directly from the exported function, but it's not clear why.
Here's the minimal test to reproduce:
package org.extism.sdk.chicory;
import com.dylibso.chicory.wasi.WasiOptions;
import junit.framework.TestCase;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class GolangTest extends TestCase {
public void testJson() throws IOException {
var wasm = ManifestWasm.fromBytes(this.getClass().getResourceAsStream("/add.wasm").readAllBytes()).build();
var manifest = Manifest.ofWasms(wasm).withOptions(new Manifest.Options().withWasi(WasiOptions.builder().build())).build();
var plugin = Plugin.ofManifest(manifest).build();
var input = "{\"a\": 20, \"b\": 21}";
var result = new String(plugin.call("add", input.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
System.out.println(result);
}
}add.wasm was compiled from the go-pdk JSON example like this:
tinygo build -o add.wasm -target wasip1 -buildmode=c-shared main.goMetadata
Metadata
Assignees
Labels
No labels