Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Apr 16, 2024
1 parent 8c6bc2f commit 4e07811
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions samples/native-stack-overflow/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ main(int argc, char *argv_main[])
goto fail;
}

unsigned int stack;
for (stack = 0; stack < 4096 * 6; stack += 1024) {
unsigned int stack;
for (stack = 0; stack < 4096 * 6; stack += 1024) {
wasm_module_inst_t module_inst = NULL;
wasm_exec_env_t exec_env = NULL;
const char *error = "fail";
Expand Down Expand Up @@ -126,28 +126,29 @@ main(int argc, char *argv_main[])
#endif
}
else {
exception = wasm_runtime_get_exception(module_inst);
exception = wasm_runtime_get_exception(module_inst);
#if 0
printf("call wasm function %s failed. error: %s\n", funcname, exception);
#endif
goto fail2;
}
error = "ok";
fail2:
printf("%5u | %6u | %4s | %s\n", stack, nest, error, exception ? exception : "");
error = "ok";
fail2:
printf("%5u | %6u | %4s | %s\n", stack, nest, error,
exception ? exception : "");

/*
* note: non-zero "nest" here demonstrates resource leak on longjmp
* from signal handler.
*/
//printf("nest = %d\n", nest);
// printf("nest = %d\n", nest);
if (exec_env) {
wasm_runtime_destroy_exec_env(exec_env);
}
if (module_inst) {
wasm_runtime_deinstantiate(module_inst);
}
}
}

fail:
if (module) {
Expand Down
3 changes: 2 additions & 1 deletion samples/native-stack-overflow/wasm-apps/testapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ test(uint32_t native_stack, uint32_t recurse_count)
"calling consume_stack_and_call_indirect(consume_stack, %u, %u)\n",
(unsigned int)i, (unsigned int)native_stack);
#endif
ret = consume_stack_and_call_indirect(consume_stack, recurse_count, native_stack);
ret = consume_stack_and_call_indirect(consume_stack, recurse_count,
native_stack);
#if 0
printf(
"consume_stack_and_call_indirect(consume_stack) returned ret=%u\n",
Expand Down

0 comments on commit 4e07811

Please sign in to comment.