-
Notifications
You must be signed in to change notification settings - Fork 91
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
Workaround the lifecycle management issue of IImportRegistration. #657
Workaround the lifecycle management issue of IImportRegistration. #657
Conversation
It avoids a testing crash.
Codecov Report
@@ Coverage Diff @@
## master #657 +/- ##
=======================================
Coverage 81.60% 81.61%
=======================================
Files 260 260
Lines 34675 34677 +2
=======================================
+ Hits 28297 28301 +4
+ Misses 6378 6376 -2
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
It helps catch issues like #653.
The last commit enabling RelWithDebInfo manifests additional memory leaks:
I can verify that loading and unloading remote_service_admin_dfi will lead to ASAN report and that adding I suspect they relate to some global shared object resource. |
One leak turns out to be caused by
https://github.com/civetweb/civetweb/blob/master/docs/api/mg_init_library.md This shows that doing global initialization (for CURL/civetweb) inside a customized launcher library is a must. @xuzhenbao |
Another leak in The solution is simple, link libffi to the executable: target_link_libraries(test_tm_scoped PRIVATE
Celix::framework
GTest::gtest
jansson::jansson
calculator_api
Celix::rsa_common
CURL::libcurl
civetweb::civetweb
libffi::libffi
) Again, we should remind our users to link libffi to their custom launcher if they need Celix components depend on libffi. |
The failure of
https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser |
Whew! I have fixed these leaks lurking in our tests for a very long time. IMHO, we should warn our users very loudly in our documentation of these shared object initialization/de-initialization pitfalls. WDYT? @pnoltes @rlenferink |
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.
LGTM.
My compliments to finding these issues. These issues are clear if you know what the problem and solution is, but hard to find given cryptic memory errors.
That they are hard to find is of course also the reason why these issues are present in our code base for quite some time.
I agree, both in warning for init/deinit library requirements in the documentation and that this should be solved in a custom launcher. An alternative to consider is to provided init/deinit libs that use the But IMO it is clearer to do this in the launcher. Maybe some effort can be made to make it possible that a custom launcher can easily use the |
IMO this PR is also needed for the 2.4.0 release, so I will wait for a merge before starting a new vote. |
Indeed, manual initialization in launcher is less than ideal. |
It's interesting to observe that libxml2 does have its destructor defined: https://github.com/GNOME/libxml2/blob/c7ff438b830d8ebeac684f3f8ad3229587c88373/threads.c#L665-L677 #if defined(HAVE_ATTRIBUTE_DESTRUCTOR) && !defined(LIBXML_STATIC) && \
!defined(_WIN32)
static void
ATTRIBUTE_DESTRUCTOR
xmlDestructor(void) {
/*
* Calling custom deallocation functions in a destructor can cause
* problems, for example with Nokogiri.
*/
if (xmlFree == free)
xmlCleanupParser();
}
#endif Thus there is no need to call |
It will be automatically called by libxml2 destructor xmlDestructor.
It avoids a testing crash.
Considering we just make bundle uninstall product-ready in 2.4.0 and OSGi permits uninstalling a bundle independent of other bundles, we can delay #653 until the 3.0.0 release.