Code Monkey home page Code Monkey logo

Comments (8)

TianlongLiang avatar TianlongLiang commented on June 13, 2024

Do you have a minimal reproducible example? Maybe I can give it a try to see where went wrong

from wasm-micro-runtime.

kamylee avatar kamylee commented on June 13, 2024

generate wasm:
/E/WorkSpace/DownLoads/wasi-sdk-21.0.m-mingw/wasi-sdk-21.0+m/bin/clang -O3 -nostdlib \ -z stack-size=32768 -Wl,--initial-memory=65536 \ -o test.wasm test.c \ -Wl,--export=main -Wl,--export=__main_argc_argv -Wl,--export=test1 \ -Wl,--export=__heap_base -Wl,--export=__data_end \ -Wl,--no-entry -Wl,--strip-all -Wl,--allow-undefined

generate aot:
wamrc -o test.aot test.wasm

code in test.c:
`void test1()
{
char *buf;

buf = malloc(1024);
if (!buf) {
    printf("malloc buf failed\n");
    return;
}

//call native function
foo2("hello 123", buf, 1024);
printf("%s\n",buf );

free(buf);

}`
it'll call native function foo2 in iwasm.exe.
enter command like this: iwasm --heap-size=16384 -f test1 test.wasm
it's run ok.
iwasm --heap-size=16384 -f test1 test.aot
it's error.

image
Release.zip
all test file is in Release.zip.

from wasm-micro-runtime.

TianlongLiang avatar TianlongLiang commented on June 13, 2024

From you snapshot, I think maybe it's a platform specific question on windows, I tested it on ubuntu 20.04, it seems no error appears with foo2 implemented as following:

static void
foo2_wrapper(wasm_exec_env_t exec_env, char *name, char *result, int resultlen)
{
    strncpy(result, name, resultlen);
}

static NativeSymbol native_symbols[] = {
    REG_NATIVE_FUNC(foo2, "($*~)")
};

I will try it on Windows to see where went wrong

from wasm-micro-runtime.

kamylee avatar kamylee commented on June 13, 2024

I also tried it in Ubuntu 22.04 and it ran okay with local variables. it seems to be a specific error on the Windows platform. thank you! wait for your conclusion!

from wasm-micro-runtime.

TianlongLiang avatar TianlongLiang commented on June 13, 2024

Hi, could you please tell me whether you compiled the iwasm and wamrc with the latest commit? I didn't see similar error on Windows

from wasm-micro-runtime.

kamylee avatar kamylee commented on June 13, 2024

the commit date is 2024/3/26 17:55:53
image

from wasm-micro-runtime.

TianlongLiang avatar TianlongLiang commented on June 13, 2024

Can you try with the latest commit and recompile both the iwasm and wamrc to see whether the error is still?

from wasm-micro-runtime.

kamylee avatar kamylee commented on June 13, 2024

thank you very much,It's running ok after the update. :)

from wasm-micro-runtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.