Skip to content

Conversation

@no1wudi
Copy link
Collaborator

@no1wudi no1wudi commented Aug 9, 2022

Add a new option WAMR_BUILD_STACK_GUARD_SIZE to use custom stack guard size,
for most RTOS port, we use stack base as check boundry which may not safety as POSIX based system (like linux).

no1wudi added 2 commits August 9, 2022 18:37
Change-Id: I2b859d242eb3fa41bdd2683b20951ff400e9a856
@lum1n0us
Copy link
Contributor

Just a little confused about the meaning of when exec_env->native_stack_boundary is NULL. Does it mean one of the below?

  • be easy, there is no stack boundary at all.
  • or, be panic, there is something wrong. There should always be value.

@no1wudi
Copy link
Collaborator Author

no1wudi commented Aug 11, 2022

@lum1n0us In current implementation, I think NULL means there is no stack boundary at all.

@wenyongh
Copy link
Collaborator

@lum1n0us In current implementation, I think NULL means there is no stack boundary at all.

Some platforms doesn't provide the related API to get native stack boundary,
so we return NULL in API os_thread_get_stack_boundary, e.g. alios.

@lum1n0us
Copy link
Contributor

in that case, such a comparison looks a little wired. It will be passed but ...

    //  if (&module_inst < NULL)
    if ((uint8 *)&module_inst < exec_env->native_stack_boundary) {
        aot_set_exception_with_id(module_inst, EXCE_NATIVE_STACK_OVERFLOW);
        return false;
    }

Would one of the below be better?

  • if (!exec_env->native_stack_boundary && &moudle_inst < exec_env->native_stack_bounbdary)
  • Or use UINT64_MAX instead of NULL if native_stack_boundary isn't provided.

@wenyongh
Copy link
Collaborator

in that case, such a comparison looks a little wired. It will be passed but ...

    //  if (&module_inst < NULL)
    if ((uint8 *)&module_inst < exec_env->native_stack_boundary) {
        aot_set_exception_with_id(module_inst, EXCE_NATIVE_STACK_OVERFLOW);
        return false;
    }

Would one of the below be better?

  • if (!exec_env->native_stack_boundary && &moudle_inst < exec_env->native_stack_bounbdary)
  • Or use UINT64_MAX instead of NULL if native_stack_boundary isn't provided.

No need to do that, if exec_env->native_stack_boundary is NULL, this condition
if ((uint8 *)&module_inst < exec_env->native_stack_boundary) will be always false,
here the check is OK. The issue is in the platform API itself.

@wenyongh wenyongh merged commit 88cf1e3 into bytecodealliance:main Aug 12, 2022
@no1wudi no1wudi deleted the guard branch August 28, 2022 14:17
loganek pushed a commit to loganek/wasm-micro-runtime that referenced this pull request Aug 31, 2022
Add a new option WAMR_BUILD_STACK_GUARD_SIZE to set the custom
stack guard size. For most RTOS systems, we use the native stack base
address as the check boundary which may be not safe as POSIX based
systems (like Linux).
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Add a new option WAMR_BUILD_STACK_GUARD_SIZE to set the custom
stack guard size. For most RTOS systems, we use the native stack base
address as the check boundary which may be not safe as POSIX based
systems (like Linux).
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

Successfully merging this pull request may close these issues.

3 participants