wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Support custom stack guard size

Open no1wudi opened this issue 1 year ago • 0 comments

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 avatar Aug 09 '22 10:08 no1wudi

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.

lum1n0us avatar Aug 11 '22 08:08 lum1n0us

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

no1wudi avatar Aug 11 '22 08:08 no1wudi

@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.

wenyongh avatar Aug 11 '22 08:08 wenyongh

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.

lum1n0us avatar Aug 11 '22 08:08 lum1n0us

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 avatar Aug 11 '22 10:08 wenyongh