wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Calling host functions in c-api error ?

Open orangeC23 opened this issue 2 years ago • 3 comments

Steps to reproduce

I tried to execute test.wat
test.txt through c-api in test-in-api.c test-in-api.txt .

In test.wat, it import 2 function from host (c file) : assert_eq_i32 and print_input. (This 2 function has 2 different types !)

The right way to import these 2 functions is to import assert_eq_i32 firstly and import print_input secondly. This is the order imported in wat file (line 139 in c file)

But I import print_input firstly and import assert_eq_i32 secondly.

Expected Result

The c api shows error or exception to alert that the first function I imported in c file are different from the first import function in wat file in type.

Actual Result

It alert nothing and regard function print_input as function assert_eq_i32 and regard function assert_eq_i32 as function print_input although they has different function types and output unexpected output of wat file.

orangeC23 avatar Jul 13 '22 09:07 orangeC23

Nice catching. We are going to create a PR to fix that.

lum1n0us avatar Jul 18 '22 07:07 lum1n0us

Thanks a lot ! Waiting for your fixing.

orangeC23 avatar Jul 18 '22 07:07 orangeC23

we've fixed the issue in the latest commits, dd62b32b201db8e5939e1084757c712145e93264.

lum1n0us avatar Jul 25 '22 02:07 lum1n0us

Close this issue as it was fixed.

wenyongh avatar Sep 22 '22 05:09 wenyongh