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

Fix two destruction order issues causing segfaults during shutdown #789

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions implementation/runtime/include/application_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <vsomeip/export.hpp>
#include <vsomeip/application.hpp>

#ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS
#include <vsomeip/internal/plugin_manager.hpp>
#endif

#ifdef ANDROID
#include "../../configuration/include/internal_android.hpp"
#else
Expand Down Expand Up @@ -382,6 +386,10 @@ class application_impl: public application,
std::string path_;
std::shared_ptr<configuration> configuration_;

#ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS
std::shared_ptr<plugin_manager> plugin_manager_;
#endif

boost::asio::io_context io_;
std::set<std::shared_ptr<std::thread> > io_threads_;
std::shared_ptr<boost::asio::executor_work_guard<
Expand Down
17 changes: 11 additions & 6 deletions implementation/runtime/src/application_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ std::mutex application_impl::app_counter_mutex__;
application_impl::application_impl(const std::string& _name, const std::string& _path) :
runtime_(runtime::get()), client_(VSOMEIP_CLIENT_UNSET), session_(0), is_initialized_(false),
name_(_name), path_(_path),
#ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS
plugin_manager_(plugin_manager::get()),
#endif
work_(std::make_shared<
boost::asio::executor_work_guard<boost::asio::io_context::executor_type>>(
io_.get_executor())),
Expand All @@ -71,7 +74,7 @@ application_impl::~application_impl() {

#ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS
if(configuration_) {
auto its_plugin = plugin_manager::get()->get_plugin(
auto its_plugin = plugin_manager_->get_plugin(
plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY);
if (its_plugin) {
auto its_configuration_plugin
Expand Down Expand Up @@ -142,7 +145,7 @@ bool application_impl::init() {
// TODO: Add loading of custom configuration module
} else { // load default module
#ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS
auto its_plugin = plugin_manager::get()->get_plugin(
auto its_plugin = plugin_manager_->get_plugin(
plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY);
if (its_plugin) {
auto its_configuration_plugin
Expand Down Expand Up @@ -354,7 +357,7 @@ bool application_impl::init() {
auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN);
if (its_app_plugin_info != its_plugins.end()) {
for (auto its_library : its_app_plugin_info->second) {
auto its_application_plugin = plugin_manager::get()->get_plugin(
auto its_application_plugin = plugin_manager_->get_plugin(
plugin_type_e::APPLICATION_PLUGIN, its_library);
if (its_application_plugin) {
VSOMEIP_INFO << "Client 0x" << std::hex << get_client()
Expand Down Expand Up @@ -486,7 +489,7 @@ void application_impl::start() {
auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN);
if (its_app_plugin_info != its_plugins.end()) {
for (const auto& its_library : its_app_plugin_info->second) {
auto its_application_plugin = plugin_manager::get()->get_plugin(
auto its_application_plugin = plugin_manager_->get_plugin(
plugin_type_e::APPLICATION_PLUGIN, its_library);
if (its_application_plugin) {
std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
Expand Down Expand Up @@ -562,7 +565,7 @@ void application_impl::stop() {
auto its_app_plugin_info = its_plugins.find(plugin_type_e::APPLICATION_PLUGIN);
if (its_app_plugin_info != its_plugins.end()) {
for (const auto& its_library : its_app_plugin_info->second) {
auto its_application_plugin = plugin_manager::get()->get_plugin(
auto its_application_plugin = plugin_manager_->get_plugin(
plugin_type_e::APPLICATION_PLUGIN, its_library);
if (its_application_plugin) {
std::dynamic_pointer_cast<application_plugin>(its_application_plugin)->
Expand Down Expand Up @@ -2251,8 +2254,10 @@ void application_impl::shutdown() {
}

try {
if (routing_)
if (routing_) {
routing_->stop();
routing_.reset();
}
} catch (const std::exception &e) {
VSOMEIP_ERROR << "application_impl::" << __func__ << ": stopping routing, "
<< " catched exception: " << e.what();
Expand Down
Loading