Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOT function call crashes due to issues with handling variable length types #4118

Open
sosotan opened this issue Feb 27, 2025 · 1 comment
Open

Comments

@sosotan
Copy link

sosotan commented Feb 27, 2025

Defining these types as function parameters can lead to this issue:size_t、intptr_t、long、void*

The wasm compiler defines size_t as 32-bit,but the aot runtime compile with msvc_x86_64,the size_t is 64-bit。

If we define a function in wasm with size_t param:
foo(size_t a, size_t b, size_t c, size_t d, size_t e) // size_t as 32-bit

and it will call into aot runtime:
aot_foo(size_t a, size_t b, size_t c, size_t d, size_t e) // size_t as 64-bit

The program may crash。

The reason is due to stack imbalance, especially for functions with more than 4 parameters, because the convention of MSVC is that the first 4 parameters are passed through registers, and the 5th parameter starts to be passed through the stack。

@TianlongLiang
Copy link
Collaborator

Are you registering some native API? If so, you can refer to this document to use correct function signature to handle issue like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants