Skip to content
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

Concurrent bundle.stop() and framework.stop() -- SCRExtensionRegistry::Find(long bundleId) #984

Open
tcormackMW opened this issue Jan 4, 2024 · 0 comments

Comments

@tcormackMW
Copy link
Contributor

tcormackMW commented Jan 4, 2024

If you run:

usDeclarativeServicesTests --gtest_filter=ComponentConfigurationTests.TestConcurrentStop --gtest_repeat=-1 --gtest_break_on_failure

and let it go for a while (between 600-10,000 runs usually) an error will come up with this function. The function is:

        std::shared_ptr<SCRBundleExtension>
        SCRExtensionRegistry::Find(long bundleId) noexcept
        {
            std::lock_guard<std::mutex> l(extensionRegMutex);
            if (auto const& it = extensionRegistry.find(bundleId); it != extensionRegistry.end())
            {
                return it->second;
            }
            return nullptr;
        }

The error comes on the call to exensionRegistry.find(bundleId). The stack is:


cppmicroservices::scrimpl::SCRExtensionRegistry::Find(cppmicroservices::scrimpl::SCRExtensionRegistry * const this, long bundleId) (CppMicroServices/compendium/DeclarativeServices/src/SCRExtensionRegistry.cpp:42)
cppmicroservices::scrimpl::SCRActivator::DisposeExtension(cppmicroservices::scrimpl::SCRActivator * const this, const cppmicroservices::Bundle & bundle) (CppMicroServices/compendium/DeclarativeServices/src/SCRActivator.cpp:195)
cppmicroservices::scrimpl::SCRActivator::BundleChanged(cppmicroservices::scrimpl::SCRActivator * const this, const cppmicroservices::BundleEvent & evt) (CppMicroServices/compendium/DeclarativeServices/src/SCRActivator.cpp:224)
cppmicroservices::ServiceListeners::BundleChanged(cppmicroservices::ServiceListeners * const this, const cppmicroservices::BundleEvent & evt) (CppMicroServices/framework/src/service/ServiceListeners.cpp:328)
cppmicroservices::BundlePrivate::Stop1(cppmicroservices::BundlePrivate * const this) (CppMicroServices/framework/src/bundle/BundlePrivate.cpp:127)
cppmicroservices::BundlePrivate::Stop0(cppmicroservices::BundlePrivate * const this) (CppMicroServices/framework/src/bundle/BundlePrivate.cpp:112)
cppmicroservices::BundlePrivate::Stop(cppmicroservices::BundlePrivate * const this, uint32_t options) (CppMicroServices/framework/src/bundle/BundlePrivate.cpp:94)
cppmicroservices::Bundle::Stop(cppmicroservices::Bundle * const this, uint32_t options) (CppMicroServices/framework/src/bundle/Bundle.cpp:144)
cppmicroservices::Bundle::Stop(cppmicroservices::Bundle * const this) (CppMicroServices/framework/src/bundle/Bundle.cpp:133)

In this case, the bundleId is valid but the data structure extensionRegistry has been reset... race condition is occuring

This also happens 2 lines down in SCRActivator::DisposeExtension on removal of the bundle... meaning that we successfully found it, and then in between the call to Find() and Remove(), the object extensionRegistry was destroyed.

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

No branches or pull requests

1 participant