Attestation: free JSON from the Wasm module heap #2803
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dear developers,
The JSON evidence is allocated on the module instance heap, but no API was given to dispose of this memory buffer.
The sample mentions using the function
free
, which (I think) behaves differently depending on the execution context.Typically, using the attestation API in a loop in a complex program (AOT) leads to a sudden stop of the program (without error output).
After investigation, I discovered that calling
free
in the Wasm app to dispose of the JSON evidence was the issue.While the logic of memory allocation is quite complex to understand and have a full picture of it, my understanding is that calling
free
from the Wasm app may be different than calling themodule_free
macro in the runtime.Since the JSON evidence is allocated using
module_malloc
, the corresponding free logic must be called accordingly.This fix provides a new function called
librats_dispose_evidence_json
, enabling to free the JSON evidence directly from the Wasm app.