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

Lens module memory management is broken #62

Closed
AndrewSisley opened this issue Nov 8, 2023 · 0 comments
Closed

Lens module memory management is broken #62

AndrewSisley opened this issue Nov 8, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@AndrewSisley
Copy link
Collaborator

AndrewSisley commented Nov 8, 2023

At the moment, the allocation of memory for input params is owned by the host, yet the freeing is handled by the module.

The return param allocation is managed by the module, but the freeing is not done explicitly (this might be a rare race condition, or a leak).

I think we need to add a new module free(ptr, size) function. The host should call into the wasm module to free input and return values, and allocate input memory. Allocating return value mem can remain within the module.

New Lens tests need too be written, as there is at least one test gap here, that was only caught by defra: TestSchemaMigrationQueryMigrationCopiesExistingFieldWhenSrcFieldNotRequested - relied on a previous memory leak encouraged by the current model.

AndrewSisley added a commit to AndrewSisley/defradb that referenced this issue Nov 8, 2023
It only half fixes this, it will be solved properly in lens-vm/lens#62
@AndrewSisley AndrewSisley added the bug Something isn't working label Nov 8, 2023
AndrewSisley added a commit to AndrewSisley/defradb that referenced this issue Nov 10, 2023
It only half fixes this, it will be solved properly in lens-vm/lens#62
AndrewSisley added a commit to AndrewSisley/defradb that referenced this issue Nov 10, 2023
It only half fixes this, it will be solved properly in lens-vm/lens#62
AndrewSisley added a commit to sourcenetwork/defradb that referenced this issue Nov 10, 2023
## Relevant issue(s)

Resolves #2036

## Description

Fix module relying on closed memory leak.

It only half fixes this, it will be solved properly in lens-vm/lens#62
@AndrewSisley AndrewSisley self-assigned this Nov 16, 2023
shahzadlone pushed a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
## Relevant issue(s)

Resolves sourcenetwork#2036

## Description

Fix module relying on closed memory leak.

It only half fixes this, it will be solved properly in lens-vm/lens#62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant