Skip to content

ignoring memory leak in specific test #1754

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
petrosagg opened this issue Mar 28, 2021 · 3 comments
Closed

ignoring memory leak in specific test #1754

petrosagg opened this issue Mar 28, 2021 · 3 comments

Comments

@petrosagg
Copy link
Contributor

Hi! I have a specific test in my crate that calls std::mem::leak on purpose to verify that the crate maintains its invariants even under those circumstances. Is there a non-global way of disabling leak check for the particular test?

@RalfJung
Copy link
Member

No, that is currently not possible. The leak check happens once, all the way at the end of execution, and just checks that there are no allocations left -- so without a lot of extra infrastructure, we cannot tell which code performed the allocation.

In the standard library, what we usually did is to keep a raw pointer to the leaking allocation somewhere, so that we can properly deallocate it at the end of the test. An alternative would be to do two runs of the test suite, where only the second includes the leaky test, and do the second run with -Zmiri-ignore-leaks.

@petrosagg
Copy link
Contributor Author

Ah, good idea with the raw pointer! I'll do that instead, thank you

@RalfJung
Copy link
Member

Also, Cc #1481

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants