samples/native-stack-overflow: add another test

This commit is contained in:
YAMAMOTO Takashi 2024-04-23 16:47:49 +09:00
parent 74d9659e22
commit 2fb5c35159
4 changed files with 22 additions and 21 deletions

View File

@ -1,16 +1,18 @@
#!/bin/bash #!/bin/bash
NAME=${1:-test1}
echo "====== Interpreter" echo "====== Interpreter"
out/native-stack-overflow out/wasm-apps/testapp.wasm out/native-stack-overflow out/wasm-apps/testapp.wasm ${NAME}
echo echo
echo "====== Interpreter WAMR_DISABLE_HW_BOUND_CHECK=1" echo "====== Interpreter WAMR_DISABLE_HW_BOUND_CHECK=1"
out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm ${NAME}
echo echo
echo "====== AOT" echo "====== AOT"
out/native-stack-overflow out/wasm-apps/testapp.wasm.aot out/native-stack-overflow out/wasm-apps/testapp.wasm.aot ${NAME}
echo echo
echo "====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1" echo "====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1"
out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm.aot.bounds-checks out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm.aot.bounds-checks ${NAME}

View File

@ -40,10 +40,11 @@ main(int argc, char **argv)
char *buffer; char *buffer;
char error_buf[128]; char error_buf[128];
if (argc != 2) { if (argc != 3) {
return 2; return 2;
} }
char *module_path = argv[1]; const char *module_path = argv[1];
const char *funcname = argv[2];
wasm_module_t module = NULL; wasm_module_t module = NULL;
uint32 buf_size; uint32 buf_size;
@ -124,7 +125,6 @@ main(int argc, char **argv)
goto fail2; goto fail2;
} }
const char *funcname = "test";
wasm_function_inst_t func = wasm_function_inst_t func =
wasm_runtime_lookup_function(module_inst, funcname); wasm_runtime_lookup_function(module_inst, funcname);
if (!func) { if (!func) {

View File

@ -54,7 +54,7 @@ host_consume_stack_and_call_indirect(wasm_exec_env_t exec_env, uint32_t funcidx,
return call_indirect(exec_env, funcidx, x); return call_indirect(exec_env, funcidx, x);
} }
static uint32_t __attribute__((noinline)) static uint32_t
consume_stack1(wasm_exec_env_t exec_env, void *base, uint32_t stack) consume_stack1(wasm_exec_env_t exec_env, void *base, uint32_t stack)
{ {
void *fp = __builtin_frame_address(0); void *fp = __builtin_frame_address(0);

View File

@ -39,14 +39,9 @@ host_consume_stack_cb(int x)
return host_consume_stack(x); return host_consume_stack(x);
} }
__attribute__((export_name("test"))) uint32_t __attribute__((export_name("test1"))) uint32_t
test(uint32_t native_stack, uint32_t recurse_count) test1(uint32_t native_stack, uint32_t recurse_count)
{ {
uint32_t ret;
#if 0 /* notyet */
ret = host_consume_stack_and_call_indirect(cb, 321, native_stack);
#endif
/* /*
* ------ os_thread_get_stack_boundary * ------ os_thread_get_stack_boundary
* ^ * ^
@ -65,11 +60,15 @@ test(uint32_t native_stack, uint32_t recurse_count)
* *
* *
*/ */
ret = host_consume_stack_and_call_indirect(consume_stack_cb, recurse_count, uint32_t ret = host_consume_stack_and_call_indirect(
native_stack); consume_stack_cb, recurse_count, native_stack);
#if 0 /* notyet */ return 42;
ret = host_consume_stack_and_call_indirect(host_consume_stack_cb, 1000000, }
native_stack);
#endif __attribute__((export_name("test2"))) uint32_t
test2(uint32_t native_stack, uint32_t recurse_count)
{
uint32_t ret = host_consume_stack_and_call_indirect(host_consume_stack_cb,
6000, native_stack);
return 42; return 42;
} }