Skip to content
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

Merged
merged 2 commits into from
Jul 16, 2020

Conversation

axic
Copy link
Member

@axic axic commented Jun 8, 2020

No description provided.

@axic
Copy link
Member Author

axic commented Jun 8, 2020

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.

@axic axic force-pushed the engine-test branch 2 times, most recently from 6107d0e to c29e3fa Compare June 30, 2020 15:23
@axic axic marked this pull request as ready for review June 30, 2020 15:24
@axic axic requested review from chfast and gumb0 June 30, 2020 15:24
@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #381 into master will increase coverage by 0.06%.
The diff coverage is 100.00%.

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

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ret != m3Err_none && ret != m3Err_functionLookupFailed)
return (ret == m3Err_none || ret == m3Err_functionLookupFailed);

Copy link
Member Author

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.

Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How this is known?

Copy link
Member Author

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.

Copy link
Member Author

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

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can disable it.

@axic
Copy link
Member Author

axic commented Jul 16, 2020

@chfast @gumb0 suggest we merge this.

@axic axic requested review from gumb0 and chfast July 16, 2020 16:55
return false;
}

auto ret = m3_LinkRawFunction(module, "env", "adler32", "i(ii)", env_adler32);
if (ret != m3Err_none && ret != m3Err_functionLookupFailed)
{
m3_FreeRuntime(m_runtime);
Copy link
Member Author

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

@axic axic merged commit 1cc68df into master Jul 16, 2020
@axic axic deleted the engine-test branch July 16, 2020 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants