Comments (4)
Maybe the second way is better, since the issue not only occurs in the host function, but also may occur in runtime, .e.g. allocating argv buffer in wasm_runtime_invoke_native:
wasm-micro-runtime/core/iwasm/common/wasm_runtime_common.c
Lines 4916 to 4921 in 30426be
It didn't happen since it is allocated only when the default buffer in local variable isn't enough and by default the latter is large enough (allows to call a wasm/host function with 31 arguments).
If we only care about the memory allocated by wasm_runtime_malloc, maybe we can auto handle it wasm_runtime_malloc, wasm_runtime_free and after longjmp:
- in wasm_runtime_malloc, check whether runtime is calling the wasm/host function (e.g. whether the global
exec_env_tls
is not NULL and its jmp stack isn't NULL), and if yes, allocate an extra node to take the memory allocated, and add the node into current WASMJmpBuf's node list - in wasm_runtime_free, remove node which has the memory pointer to free in current WASMJmpBuf's node list
- after longjmp, free current WASMJmpBuf's node list and the memory pointers inside them
from wasm-micro-runtime.
Maybe the second way is better, since the issue not only occurs in the host function, but also may occur in runtime, .e.g. allocating argv buffer in wasm_runtime_invoke_native:
right now i'm inclined towards the first approach because those checks are necessary for OS_ENABLE_HW_BOUND_CHECK=0 anyway.
from wasm-micro-runtime.
OK, and it would be good if we also fix the argv buffer allocation issue in wasm_runtime_invoke_native.
from wasm-micro-runtime.
another reason why (b) isn't enough is host-provided apis like libc functions.
when we hit the guard pages in the middle of libc, it's impossible to recover gracefully.
from wasm-micro-runtime.
Related Issues (20)
- aot_load_const_from_table is inefficient
- "duplicate export name" check is O(n^2) HOT 3
- Compilation errors when build iwasm with GC and EH support
- iwasm: WASM module load failed: struct or array as field is not supported in constant expr HOT 6
- iwasm: WASM module load failed: type mismatch: expect (ref null ht) but got other1 unknown type HOT 8
- exception handler intercepts c++ exceptions in the host on windows HOT 4
- WASM module instantiate failed on Mac HOT 1
- aot: xtensa xip triggers llvm assertion failure
- BH_DEBUG not set in multi-configuration cmake (eg. visual studio)
- printf_wrapper (libc builtin) makes multiple calls to os_printf with individual characters HOT 6
- Can AOT file built on windows run directly on other platforms? HOT 5
- How to load and run another wasm in a running wasm? HOT 12
- Exception Handling Support in Fast Interpreter HOT 1
- iwasm with aot file fail with SIGSEGV HOT 4
- Exception for Assemblyscript HOT 1
- How to cross compile to riscv64 HOT 2
- Unexpected behavior on fast interpreter mode HOT 2
- A bug in validation HOT 2
- Report some typo in wamr.gitbook HOT 1
- Calling "step-over" on the last line of the function failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasm-micro-runtime.