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

Fix allocate and free_mem #112

Merged
merged 2 commits into from
May 8, 2024
Merged

Fix allocate and free_mem #112

merged 2 commits into from
May 8, 2024

Conversation

ureeves
Copy link
Member

@ureeves ureeves commented May 8, 2024

The use of mem::forget is extremely dangerous, as it gives no guarantee that the forgotten memory won't be clobbered. This PR fixes this making explicit use of the global allocator via the alloc and dealloc functions.

The one downside is that we explicitly copy returns from the module on every function call.

Resolves: #105

@ureeves ureeves requested review from ZER0, Daksh14 and moCello May 8, 2024 13:17
@ureeves ureeves changed the base branch from wasmtime to main May 8, 2024 13:24
Eduardo Leegwater Simões added 2 commits May 8, 2024 15:25
This is done by allocating a dedicated buffer and copying the contents
of the response into it.
This makes the allocator explicitly responsible for the memory
allocated, preventing any clobbering.
@ureeves ureeves changed the base branch from main to wasmtime May 8, 2024 13:25
Copy link
Member

@moCello moCello left a comment

Choose a reason for hiding this comment

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

LGTM

@ureeves ureeves merged commit 7f18666 into wasmtime May 8, 2024
4 checks passed
@ureeves ureeves deleted the fix-alloc branch May 8, 2024 13:55
@moCello moCello mentioned this pull request May 13, 2024
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.

2 participants