-
Notifications
You must be signed in to change notification settings - Fork 114
Fix memleaks in module.c #1602
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
base: release-0.6
Are you sure you want to change the base?
Fix memleaks in module.c #1602
Conversation
433ac33
to
a177f52
Compare
This fixes some of the memleaks found by ASAN on CI. See https://github.com/software-mansion-labs/FissionVM/tree/ci-asan These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later Signed-off-by: Mateusz Front <[email protected]>
a177f52
to
caa6ee8
Compare
free(module->imported_funcs); | ||
free(module->literals_table); | ||
free(module->local_atoms_to_global_table); | ||
if (module->free_literals_data) { | ||
free(module->literals_data); | ||
} | ||
free(module->line_refs); | ||
free(module->filenames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense only in main
since filenames
is not available in release-0.6 branch.
The correct fix would be splitting this PR in 2, one for release-0.6 and one for main, but:
this memory leak for now is relevant only during tests so it doesn't have any practical impact on devices running release-0.6, so we can go for the lazy option that is basing this on top of main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't build right now.
@@ -116,6 +116,7 @@ struct Module | |||
struct ListHead line_ref_offsets; | |||
|
|||
const struct ExportedFunction **imported_funcs; | |||
int functions_count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of saving sizeof(int) for every module, I would argue for recomputing this when the module is destroyed, especially considering we don't destroy modules at all for now.
This fixes some of the memleaks found by ASAN running tests on Ubuntu. I believe having ASAN enabled on the AtomVM's CI would be beneficial, as there are still some memleaks out there
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later