Skip to content

Use valgrind to simplify no-leak regression testing #72

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

Closed
vaind opened this issue Nov 18, 2019 · 0 comments
Closed

Use valgrind to simplify no-leak regression testing #72

vaind opened this issue Nov 18, 2019 · 0 comments
Labels
good first issue Good for newcomers help wanted Looking for contributors (ideas, comments, code, etc)
Milestone

Comments

@vaind
Copy link
Contributor

vaind commented Nov 18, 2019

Seems like we can detect leaks using valgrind:

dart2native ./test/box_test.dart -o box-test
valgrind --show-mismatched-frees=no ./box-test
==13549== LEAK SUMMARY:
==13549==    definitely lost: 0 bytes in 0 blocks
==13549==    indirectly lost: 0 bytes in 0 blocks
==13549==      possibly lost: 0 bytes in 0 blocks
==13549==    still reachable: 91,012 bytes in 188 blocks
==13549==         suppressed: 0 bytes in 0 blocks

And If I manually comment out a free() call on an ffi.Pointer (e.g. in box.count()), it shows a leak:

==13580== LEAK SUMMARY:
==13580==    definitely lost: 128 bytes in 16 blocks
==13580==    indirectly lost: 0 bytes in 0 blocks
==13580==      possibly lost: 0 bytes in 0 blocks
==13580==    still reachable: 91,012 bytes in 188 blocks
==13580==         suppressed: 0 bytes in 0 blocks

Similarly, when I comment out a call to obx_query_close() and run valgrind on the query-test, it catches a leak of the core resources as well:

==15074== LEAK SUMMARY:
==15074==    definitely lost: 6,200 bytes in 181 blocks
==15074==    indirectly lost: 218,547 bytes in 3,199 blocks
==15074==      possibly lost: 0 bytes in 0 blocks
==15074==    still reachable: 91,012 bytes in 188 blocks
==15074==         suppressed: 0 bytes in 0 blocks

Therefore, it is clear it can help detect leaks that could be potentially introduced in the future code changes. There is also a load of Warning: set address range perms: large range and mismatched free() / delete / delete [] reports but I don't think those are related to our code, at least for the latter. That would require further investigation though.

Goal

Create a script for project developers and CI. The script:

  • compiles all /test/*_test.dart files using dart2native
  • executes each compiled test using valgrind
  • capture the leak summary and show an error to the user if there is a leak (any non-zero "lost" report)

The script should ideally return a non-zero code in case of an error, so it can easily be used in the CI.

@vaind vaind added help wanted Looking for contributors (ideas, comments, code, etc) good first issue Good for newcomers labels Nov 18, 2019
@vaind vaind changed the title Use valgrind to test there are no leaks Use valgrind to simplify no-leak regression testing Nov 25, 2019
@vaind vaind added this to the 1.0 milestone Jan 21, 2021
@vaind vaind closed this as completed in 92b2f10 Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Looking for contributors (ideas, comments, code, etc)
Projects
None yet
Development

No branches or pull requests

1 participant