second-state / wasm-joey

Serverless Wasm - A lightweight Node.js application for deploying and executing WebAssembly(Wasm) binary-code via HTTP
https://www.secondstate.io/
Apache License 2.0
55 stars 9 forks source link

Error executing this function, please check function name, input parameters, return parameter for correctness #31

Closed burakakca closed 2 years ago

burakakca commented 3 years ago

I run server and upload this hello wasm example then i run on postman below code

curl --location --request POST 'https://127.0.0.1:8081/api/run/1/say' \
--header 'Content-Type: text/plain' \
--data-raw 'Tim'

Response error;

{"return_value":"Error executing this function, please check function name, input parameters, return parameter for
correctness"}

Console error;

1,b212ab14-f2e4-4104-b7a3-b9ee75312b37.so
Loading 1's AOT file into cache (b212ab14-f2e4-4104-b7a3-b9ee75312b37.so)
/api/run/:wasm_id/:function_name ...
Creating log object
No callback found in the header keys
No fetchable information found in the header keys
SSVM Options: {"EnableAOT":true,"EnableMeasurement":true,"args":["{}"],"env":{"wasm_id":"1","storage_key":"6008e2a80d77b1d22eb5752357dac64e"},"preopens":{"/":"/tmp"}}
Instantiating SSVM with AOT filename of: aot/b212ab14-f2e4-4104-b7a3-b9ee75312b37.so which has a typeof: string
Instantiation success!
It is resolved that the JSON object is not empty, returning to function execution ...
Parameters len == 1
Executing function WITHOUT a callback...
[2021-10-19 12:24:00.055] [error] instantiation failed: unknown import, Code: 0x62
[2021-10-19 12:24:00.055] [error]     When linking module: "__wbindgen_placeholder__" , function name: "__wbindgen_describe"
[2021-10-19 12:24:00.055] [error]     At AST node: import description
[2021-10-19 12:24:00.055] [error]     At AST node: import section
[2021-10-19 12:24:00.055] [error]     At AST node: module
alabulei1 commented 3 years ago

Thanks for your feedback. @juntao and @tpmccallum could you take a look? Maybe because we renamed the SSVM to WasmEdge-core?

tpmccallum commented 2 years ago

Hi, Thanks, checking on this now. Tim

tpmccallum commented 2 years ago

Hi, It seems that this is only an issue with the AOT compiled binary. For example, if I compile this hello world example [1] using rustwasmc build and then run the .wasm using the following node CLI (for simplicity and demonstration purposes) it works find.

// Create ssvm instance
const ssvm = require("wasmedge-extensions");
// Load Wasm
const path = "/home/tpmccallum/hello_lib_bg.wasm";
vm = new ssvm.VM(path, { args:process.argv, env:process.env, preopens:{"/": "/tmp"} });
// Run function
var return_value = vm.RunString("say", "asdf");
console.log("Return value: " + return_value);

The following output shows success

$ node tester.js
Return value: hello asdf

Alternatively, if I use AOT compile process and run the .so instead of the .wasm then an issue occurs.

// Create ssvm instance
const ssvm = require("wasmedge-extensions");
// Load Wasm
const path = "/home/tpmccallum/hello_lib_bg.wasm";
vm = new ssvm.VM(path, { args:process.argv, env:process.env, preopens:{"/": "/tmp"} });
// AOT
vm.Compile(aot_path);
var vm_aot = new ssvm.VM(aot_path, { EnableAOT:true, rgs:process.argv, env:process.env, preopens:{"/": "/tmp"} });
// Run function
var return_value = vm_aot.RunString("say", "asdf");
console.log("Return value: " + return_value);

The following output shows the error

[2021-10-20 09:59:08.164] [error] execution failed: out of bounds memory access, Code: 0x88
[2021-10-20 09:59:08.164] [error]     When executing function name: "__wbindgen_malloc"
[2021-10-20 09:59:08.164] [error] execution failed: function signature mismatch, Code: 0x83
[2021-10-20 09:59:08.164] [error]     Mismatched function type. Expected: params{i32 , i32 , i32} returns{} , Got: params{i32} returns{}
[2021-10-20 09:59:08.164] [error]     When executing function name: "say"
/media/nvme/node_rpc/wasm-joey/src/testing_using_node/tester.js:25
var return_value = vm_aot.RunString("say", "asdf");
                          ^

Error: out of bounds memory access
    at Object.<anonymous> (/media/nvme/node_rpc/wasm-joey/src/testing_using_node/tester.js:25:27)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'Error'
}

[1] https://github.com/second-state/wasm-learning/tree/master/faas/hello

tpmccallum commented 2 years ago

I see there was just an update regarding memory so I am just updating wasmedge-extensions to lastest 0.8.2 and will try this again.

tpmccallum commented 2 years ago

Hi @alabulei1 & @burakakca I would like to update to all the latest code and then share the outcome. There is an issue [1] in relation to wasmedge-extensions installer which when fixed will allow us to use the latest code. I will get back to you asap. Thanks [1] https://github.com/second-state/wasmedge-extensions/issues/3

tpmccallum commented 2 years ago

Hi @juntao @alabulei1 and @burakakca This should now be resolved. @burakakca please install the latest wasmedge-extensions as per this documentation and try again.

tpmccallum commented 2 years ago

Here you can see a new hello example (taken from this example) which I have uploaded to the Function As A Service (FaaS) which runs the same software. You can try calling it via Curl command in your Linux/Mac Command Line Interface (CLI)

curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/452/say' \
--header 'Content-Type: text/plain' \
--data-raw 'Tim'

Returns

hello Tim
burakakca commented 2 years ago

Yes, works well. If i get similar new error, can i open this issue

tpmccallum commented 2 years ago

Hi @burakakca Great to hear it is now working as intended. Yes, sure thing. Please share any new errors so that we can help out. Thanks for sharing.