Skip to content

An exception crash occurred when using the socket's connect method in a native function exported to wasm. #4815

@kamylee

Description

@kamylee

test platform:Win10
Wamr version :2.4.4:
wasi-sdk version:24.0
cmake command:
cmake -G "Unix Makefiles" -DWASI_SDK_PREFIX=E:/WorkSpace/wamr_source/wasi-sdk-24.0-x86_64-windows -DCMAKE_TOOLCHAIN_FILE=E:/WorkSpace/wamr_source/wasi-sdk-24.0-x86_64-windows/share/cmake/wasi-sdk.cmake -DCMAKE_SYSROOT=E:/WorkSpace/wamr_source/wasi-sdk-24.0-x86_64-windows/share/wasi-sysroot ..

Compile testapp.c with and without -nostdlib.
Generated two wasm file:
testapp.wasm(-nostdlib --no-entry)
testapp1.wasm

target_link_options(testapp1.wasm PRIVATE 
	#-nostdlib -O3					
	#LINKER:--strip-all,--no-entry	#ok 
	LINKER:--export=__heap_base		
	LINKER:--export=__data_end		
	LINKER:--export=malloc
	LINKER:--export=free		
	#LINKER:--export=__wasm_call_ctors
	LINKER:--export=generate_float
	LINKER:--export=float_to_string
	LINKER:--export=calculate
	LINKER:--export=mul7
	LINKER:--export=wasm_test1
	LINKER:--shared-memory 
	LINKER:--max-memory=6291456 #65536*96
	LINKER:--initial-memory=2097152
	LINKER:-zstack-size=524288
	LINKER:--no-check-features
	LINKER:--allow-undefined
	
)

testapp1.wasm only commented -nostdlib and LINKER:--strip-all,--no-entry

I called wasm_test() in wasm.
Then called the native function "native_test()" in wasm_test().
Then call socket's connect to connect tcp server in "native_test()" function.

Result:
testapp.wasm : success to connect server,
testapp1.wasm :faild to connect server.
0x0000000000000000 处(位于 TestDriver.exe 中)引发的异常: 0xC0000005: 执行位置 0x0000000000000000 时发生访问冲突。

Question:
Why can't thd connect function be used in libc-wasi mode?
thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions