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

src:parse: plug memory leaks in nullable handling #319

Merged
merged 1 commit into from
Jan 30, 2023

Conversation

slyon
Copy link
Collaborator

@slyon slyon commented Jan 30, 2023

Description

src:parse: plug memory leaks in nullable handling, adding some more tests to check for additional cases.

Follow-up for #299

Fixes:

$ LD_LIBRARY_PATH=_build/src/ valgrind --leak-check=full _build/tests/ctests/test_netplan_parser
[...]
==71129==
==71129== HEAP SUMMARY:
==71129==     in use at exit: 179,509 bytes in 2,284 blocks
==71129==   total heap usage: 8,205 allocs, 5,921 frees, 1,319,847 bytes allocated
==71129==
[...]
==71129==
==71129== 2,554 (1,536 direct, 1,018 indirect) bytes in 1 blocks are definitely lost in loss record 1,828 of 1,835
==71129==    at 0x4E050C5: malloc (vg_replace_malloc.c:393)
==71129==    by 0x49B92D1: yaml_parser_load (in /usr/lib/x86_64-linux-gnu/libyaml-0.so.2.0.9)
==71129==    by 0x11968A: load_yaml_from_fd (parse.c:88)
==71129==    by 0x12450E: netplan_parser_load_nullable_overrides (parse.c:3501)
==71129==    by 0x124A38: test_netplan_parser_load_nullable_overrides (test_netplan_parser.c:53)
==71129==    by 0x485E4E0: ??? (in /usr/lib/x86_64-linux-gnu/libcmocka.so.0.7.0)
==71129==    by 0x485EEC4: _cmocka_run_group_tests (in /usr/lib/x86_64-linux-gnu/libcmocka.so.0.7.0)
==71129==    by 0x1252DA: main (test_netplan_parser.c:228)
==71129==
==71129== LEAK SUMMARY:
==71129==    definitely lost: 1,536 bytes in 1 blocks
==71129==    indirectly lost: 1,018 bytes in 30 blocks
==71129==      possibly lost: 608 bytes in 2 blocks
==71129==    still reachable: 159,603 bytes in 2,071 blocks
==71129==         suppressed: 0 bytes in 0 blocks
==71129== Reachable blocks (those to which a pointer was found) are not shown.
==71129== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==71129==
==71129== For lists of detected and suppressed errors, rerun with: -s
==71129== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
==71163== Memcheck, a memory error detector
==71163== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==71163== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==71163== Command: _build/tests/ctests/test_netplan_error
==71163==

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad.

@slyon slyon requested a review from daniloegea January 30, 2023 15:51
Copy link
Collaborator

@daniloegea daniloegea left a comment

Choose a reason for hiding this comment

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

lgtm

@slyon slyon merged commit 102f189 into main Jan 30, 2023
@slyon slyon deleted the slyon/plug-nullable-leaks branch January 30, 2023 16:23
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