Open PengZheng opened 10 months ago
It has been bisected to be introduced by 6bb8de50.
But as the commit log said, celix_framework_stopBundleEntry
is unnecessary, since celix_framework_uninstallBundleEntry
will stop the bundle first. It seems more like a testing/C++ RSA issue. @pnoltes
I've verified that adding celix_framework_stopBundleEntry
back will "fix" the problem.
size = celix_arrayList_size(stopEntries);
for (int i = size-1; i >= 0; --i) { //note loop in reverse order -> stop later installed bundle first
celix_framework_bundle_entry_t *entry = celix_arrayList_get(stopEntries, i);
//NOTE possible starvation.
// fw_bundleEntry_waitTillUseCountIs(entry, 1); //note this function has 1 use count.
//note race between condition (use count == 1) and bundle stop, meaning use count can be > 1 when
//celix_framework_stopBundleEntry is called.
bundle_state_e state = celix_bundle_getState(entry->bnd);
if (state == CELIX_BUNDLE_STATE_ACTIVE || state == CELIX_BUNDLE_STATE_STARTING) {
celix_framework_stopBundleEntry(fw, entry);
}
}
for (int i = size-1; i >= 0; --i) { //note loop in reverse order -> uninstall later installed bundle first
celix_framework_bundle_entry_t *entry = celix_arrayList_get(stopEntries, i);
celix_framework_uninstallBundleEntry(fw, entry, false);
}
celix_arrayList_destroy(stopEntries);
And it can be narrowed down to the consumer bundle. The following can manifest the issue:
TEST_F(RemoteServicesIntegrationTestSuite, StartStopFrameworks) {
// installProviderBundles();
installConsumerBundles();
}
I suspect this is a lifecycle management bug of TestExportImportRemoteServiceFactory
/C++ RSA.
Note that ComponentImportRegistration
produced by CalculatorImportServiceFactory::importService
is NOT managed by CalculatorImportServiceFactory
. That means if TestExportImportRemoteServiceFactory
bundle is uninstalled, RemoteServiceAdmin
will keep references of ComponentImportRegistration
, whose destructor is not in address space anymore.
Note also that any bundle should be able to be uninstalled independent of other bundles.
This shows that any object passing through Celix service should be managed by the object owner bundle some way. WDYT? @pnoltes @rlenferink
Currently, IImportRegistration
can not tell which IImportServiceFactory
it comes from.
Otherwise, we can remove it from RemoteServiceAdmin
when the factory is stopped.
Thus, it turns out to be a design issue of cxx_remote_services.