-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add test case for failing start function in wasm_engine_test #381
Conversation
Not sure this is a fault of our binding or upstream, but it definitely isn't the fault of the patch we have as I have tried it without the patch. |
6107d0e
to
c29e3fa
Compare
Codecov Report
@@ Coverage Diff @@
## master #381 +/- ##
==========================================
+ Coverage 99.28% 99.35% +0.06%
==========================================
Files 49 49
Lines 13227 13242 +15
==========================================
+ Hits 13133 13156 +23
+ Misses 94 86 -8 |
test/utils/wasm3_engine.cpp
Outdated
@@ -84,14 +84,13 @@ bool Wasm3Engine::instantiate(bytes_view wasm_binary) | |||
// Transfers ownership to runtime. | |||
if (m3_LoadModule(m_runtime, module) != m3Err_none) | |||
{ | |||
m3_FreeModule(module); | |||
// NOTE: apparently m3_FreeModule isn't needed in neither the failure nor the success case | |||
return false; | |||
} | |||
|
|||
auto ret = m3_LinkRawFunction(module, "env", "adler32", "i(ii)", env_adler32); | |||
if (ret != m3Err_none && ret != m3Err_functionLookupFailed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ret != m3Err_none && ret != m3Err_functionLookupFailed) | |
return (ret == m3Err_none || ret == m3Err_functionLookupFailed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really dislike this setting of clang-tidy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can disable it.
@@ -84,14 +84,13 @@ bool Wasm3Engine::instantiate(bytes_view wasm_binary) | |||
// Transfers ownership to runtime. | |||
if (m3_LoadModule(m_runtime, module) != m3Err_none) | |||
{ | |||
m3_FreeModule(module); | |||
// NOTE: apparently m3_FreeModule isn't needed in neither the failure nor the success case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this is known?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By going through the wasm3 code. Basically it seem once a module is parsed you have two choices: LoadModule
or FreeModule
, and if LoadModule
was called then it is the liability of that to deal with it. Started opening in issue on their repo to clarify this, but then I guess forgot to submit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asked the question: wasm3/wasm3#160
test/utils/wasm3_engine.cpp
Outdated
@@ -84,14 +84,13 @@ bool Wasm3Engine::instantiate(bytes_view wasm_binary) | |||
// Transfers ownership to runtime. | |||
if (m3_LoadModule(m_runtime, module) != m3Err_none) | |||
{ | |||
m3_FreeModule(module); | |||
// NOTE: apparently m3_FreeModule isn't needed in neither the failure nor the success case | |||
return false; | |||
} | |||
|
|||
auto ret = m3_LinkRawFunction(module, "env", "adler32", "i(ii)", env_adler32); | |||
if (ret != m3Err_none && ret != m3Err_functionLookupFailed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can disable it.
return false; | ||
} | ||
|
||
auto ret = m3_LinkRawFunction(module, "env", "adler32", "i(ii)", env_adler32); | ||
if (ret != m3Err_none && ret != m3Err_functionLookupFailed) | ||
{ | ||
m3_FreeRuntime(m_runtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a second bugfix, since we didn't set m_runtime
to null, it may have attempted to free it twice (in the destructor).
No description provided.