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

Missing m3_Free(i_module->memoryExportName) in m3_FreeModule #460

Open
matovitch opened this issue Feb 17, 2024 · 1 comment
Open

Missing m3_Free(i_module->memoryExportName) in m3_FreeModule #460

matovitch opened this issue Feb 17, 2024 · 1 comment

Comments

@matovitch
Copy link

Hello,

I have a leak in my tests and I believe it is because the field memoryExportName isn't freed in the m3_FreeModule function:

==165799== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==165799== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==165799== by 0x5DC574: Read_utf8 (in /workspaces/dmit/bin/test/test)
==165799== by 0x5EBB83: ParseSection_Export (in /workspaces/dmit/bin/test/test)
==165799== by 0x5EC9C9: m3_ParseModule (in /workspaces/dmit/bin/test/test)

(sorry I don't have the line numbers)

The export function of my module looks like this:

Export[13]:

  • memory[0] -> "memory"
  • func[0] <__wasm_call_ctors> -> "__wasm_call_ctors"
  • func[1] -> "c75sgoIqs5aM0nJEADtPzA"
  • func[2] -> "WjJyoLoybnLBswwPRZch9Q"
  • global[1] -> "__dso_handle"
  • global[2] -> "__data_end"
  • global[3] -> "__stack_low"
  • global[4] -> "__stack_high"
  • global[5] -> "__global_base"
  • global[6] -> "__heap_base"
  • global[7] -> "__heap_end"
  • global[8] -> "__memory_base"
  • global[9] -> "__table_base"

I believe "memory" is 7 bytes with the \0 and I don't see the free in the existing code for this field (memoryExportName).

I can submit a PR if you like.

Cheers, :)

@matovitch matovitch changed the title Missing m3_Free (i_module->memoryExportName) in m3_FreeModule Missing m3_Free(i_module->memoryExportName) in m3_FreeModule Feb 17, 2024
@matovitch
Copy link
Author

wasm3_leak

This is indeed the leak, m3_Free (i_module->table0ExportName) is missing as well in m3_FreeModule.

matovitch pushed a commit to matovitch/wasm3 that referenced this issue Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant