Skip to content

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

Open
@sosotan

Description

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。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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