-
Notifications
You must be signed in to change notification settings - Fork 108
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
drop() not called automatically on FreeBSD/ HardenedBSD #49
Comments
If you want to see the whole thing, it's open source: https://github.com/VerKnowSys/sysapi/blob/master/src/lib.rs#L165 |
I have fetched your project into a FreeBSD 11.1 VM, removed the I have verified this in two distinct ways:
I have verified the same behaviour in both debug and release modes. Is there more information on the issue that would help one to uncover the issue? One easy way to verify whether |
Very interesting. One thing I'm sure of is - without that manual mem::forget(), each request calling my API was leaking ~100-200KiB of RSS in RAM. My report with not calling drop() was a guess - that's true. Now I wonder why I have to make that explicit "forget call". Thanks for checking this out! |
Second possibility is that issue is present only on HardenedBSD (is also FreeBSD using same 11-stable branch but has some additional security mitigations applied). |
Shared libraries are reference counted at the system level either way – a single |
Maybe it's not about .so loading/ unloading, but about data read (from function in my .so library) is still keeping like some strong pointer to data which is not auto freed? |
It could be the case if your shared library uses thread-locals, however libloading is oblivious to that functionality. |
My library talks to BSD kernel directly over kernel-kvm interface + procstat. Thanks for insight and your time. Much appreciated :) |
Um.. I forgot to ask - after seeing that drop() being called - have you watched Ressident Set Size of your process? Maybe drop() is called, but here I notice +100KiB RSS usage each function call (of course talking about case without |
I did not monitor RSS at all. And besides |
I’ll close this for now since I don’t see anything actionable on the |
Making a long story short:
This code without that additional "mem::forget(lib);" call, will cause lib to not call drop, and cause a memleak.
For future generations :)
The text was updated successfully, but these errors were encountered: