From e5185dd4e95e2d18d8341f3e8ac00981a5fadfa0 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Thu, 7 May 2026 16:59:51 +0200 Subject: [PATCH 01/14] debug 1 --- implementation/BUILD | 2 +- .../src/configuration_plugin_impl.cpp | 11 ++ .../plugin/src/plugin_manager_impl.cpp | 120 +++++++++++++++++- .../runtime/src/application_impl.cpp | 21 +++ 4 files changed, 151 insertions(+), 3 deletions(-) diff --git a/implementation/BUILD b/implementation/BUILD index 8ce98e2c8..56fbd56fc 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -1,7 +1,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-debug1" # Must match the git tag version. expand_template( name = "config", diff --git a/implementation/configuration/src/configuration_plugin_impl.cpp b/implementation/configuration/src/configuration_plugin_impl.cpp index a96553c87..dee195d3b 100644 --- a/implementation/configuration/src/configuration_plugin_impl.cpp +++ b/implementation/configuration/src/configuration_plugin_impl.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -22,11 +24,17 @@ std::shared_ptr configuration_plugin_impl::get_configuration(cons std::scoped_lock its_lock(mutex_); auto its_iterator = configurations_.find(_name); if (its_iterator != configurations_.end()) { + std::cerr << "[vsomeip][configuration-debug] Reusing cached configuration for application \"" << _name << "\"." + << std::endl; its_configuration = its_iterator->second; } else { + std::cerr << "[vsomeip][configuration-debug] Creating new configuration_impl for application \"" << _name + << "\" with path \"" << _path << "\"." << std::endl; its_configuration = std::make_shared(_path); its_configuration->load(_name); configurations_[_name] = its_configuration; + std::cerr << "[vsomeip][configuration-debug] Configuration loaded and cached for application \"" << _name << "\"." + << std::endl; } return its_configuration; @@ -41,6 +49,9 @@ namespace { struct configuration_plugin_static_registrar { configuration_plugin_static_registrar() { + std::cerr << "[vsomeip][configuration-debug] Static configuration plugin registrar is running. Registering " + "CONFIGURATION_PLUGIN factory with plugin_manager." + << std::endl; plugin_manager::register_static_plugin(plugin_type_e::CONFIGURATION_PLUGIN, configuration_plugin_impl::get_plugin); } diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index 9c33c94f4..ae89544ce 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -35,6 +35,25 @@ namespace vsomeip_v3 { std::shared_ptr plugin_manager_impl::the_plugin_manager__ = nullptr; +namespace { + +const char* plugin_type_to_string(plugin_type_e _type) { + switch (_type) { + case plugin_type_e::APPLICATION_PLUGIN: + return "APPLICATION_PLUGIN"; + case plugin_type_e::CONFIGURATION_PLUGIN: + return "CONFIGURATION_PLUGIN"; + case plugin_type_e::PRE_CONFIGURATION_PLUGIN: + return "PRE_CONFIGURATION_PLUGIN"; + case plugin_type_e::SD_RUNTIME_PLUGIN: + return "SD_RUNTIME_PLUGIN"; + default: + return "UNKNOWN_PLUGIN"; + } +} + +} // namespace + std::shared_ptr plugin_manager_impl::get() { static std::once_flag initialization_flag; std::call_once(initialization_flag, []() { @@ -52,58 +71,126 @@ plugin_manager_impl::~plugin_manager_impl() { std::shared_ptr plugin_manager_impl::get_plugin(plugin_type_e _type, const std::string& _name) { std::lock_guard its_lock_start_stop(plugins_mutex_); + std::cerr << "[vsomeip][plugin-debug] get_plugin requested type=" << plugin_type_to_string(_type) << " (" + << static_cast(_type) << "), name=\"" << _name << "\"." << std::endl; auto its_type = plugins_.find(_type); if (its_type != plugins_.end()) { auto its_name = its_type->second.find(_name); if (its_name != its_type->second.end()) { + std::cerr << "[vsomeip][plugin-debug] Returning cached plugin for type=" << plugin_type_to_string(_type) + << ", name=\"" << _name << "\"." << std::endl; return its_name->second; } + std::cerr << "[vsomeip][plugin-debug] Plugin cache contains type=" << plugin_type_to_string(_type) + << " but no entry named \"" << _name << "\". Loading it now." << std::endl; + } else { + std::cerr << "[vsomeip][plugin-debug] Plugin cache has no entries for type=" << plugin_type_to_string(_type) + << ". Loading requested plugin now." << std::endl; } return load_plugin(_name, _type, 1); } std::shared_ptr plugin_manager_impl::load_plugin(const std::string& _library, plugin_type_e _type, uint32_t _version) { + std::cerr << "[vsomeip][plugin-debug] load_plugin started for library=\"" << _library << "\", expected type=" + << plugin_type_to_string(_type) << " (" << static_cast(_type) << "), expected version=" << _version << "." + << std::endl; if (auto its_plugin = load_static_plugin(_type, _version)) { + std::cerr << "[vsomeip][plugin-debug] Static plugin lookup succeeded for type=" << plugin_type_to_string(_type) + << ". Caching it under name=\"" << _library << "\"." << std::endl; handles_[_type][_library] = nullptr; add_plugin(its_plugin, _library); return its_plugin; } + std::cerr << "[vsomeip][plugin-debug] Static plugin lookup failed for type=" << plugin_type_to_string(_type) + << ". Falling back to dynamic library loading for \"" << _library << "\"." << std::endl; void* handle = load_library(_library); + if (!handle) { + std::cerr << "[vsomeip][plugin-debug] Dynamic library loading returned nullptr for \"" << _library + << "\". No plugin init symbol can be loaded from this library." << std::endl; + } plugin_init_func its_init_func = reinterpret_cast(load_symbol(handle, VSOMEIP_PLUGIN_INIT_SYMBOL)); if (its_init_func) { + std::cerr << "[vsomeip][plugin-debug] Found plugin init symbol \"" << VSOMEIP_PLUGIN_INIT_SYMBOL << "\" in \"" << _library + << "\". Calling it to obtain the create_plugin function." << std::endl; create_plugin_func its_create_func = (*its_init_func)(); if (its_create_func) { + std::cerr << "[vsomeip][plugin-debug] Plugin init function returned a create_plugin function for \"" << _library + << "\". Creating plugin instance." << std::endl; handles_[_type][_library] = handle; auto its_plugin = (*its_create_func)(); if (its_plugin) { + std::cerr << "[vsomeip][plugin-debug] Dynamic plugin instance created: name=\"" << its_plugin->get_plugin_name() + << "\", type=" << plugin_type_to_string(its_plugin->get_plugin_type()) << " (" + << static_cast(its_plugin->get_plugin_type()) << "), version=" << its_plugin->get_plugin_version() + << "." << std::endl; if (its_plugin->get_plugin_type() == _type && its_plugin->get_plugin_version() == _version) { + std::cerr << "[vsomeip][plugin-debug] Dynamic plugin type/version match. Adding plugin \"" << _library + << "\" to cache." << std::endl; add_plugin(its_plugin, _library); return its_plugin; } else { + std::cerr << "[vsomeip][plugin-debug] Dynamic plugin type/version mismatch. Expected type=" + << plugin_type_to_string(_type) << " (" << static_cast(_type) << "), version=" << _version + << "; got type=" << plugin_type_to_string(its_plugin->get_plugin_type()) << " (" + << static_cast(its_plugin->get_plugin_type()) << "), version=" + << its_plugin->get_plugin_version() << "." << std::endl; VSOMEIP_ERROR << "Plugin version mismatch. Ignoring plugin " << its_plugin->get_plugin_name(); } + } else { + std::cerr << "[vsomeip][plugin-debug] Dynamic create_plugin function returned nullptr for \"" << _library << "\"." + << std::endl; } + } else { + std::cerr << "[vsomeip][plugin-debug] Plugin init symbol returned a nullptr create_plugin function for \"" << _library + << "\"." << std::endl; } + } else { + std::cerr << "[vsomeip][plugin-debug] Plugin init symbol \"" << VSOMEIP_PLUGIN_INIT_SYMBOL << "\" was not available for \"" + << _library << "\"." << std::endl; } + std::cerr << "[vsomeip][plugin-debug] load_plugin failed for library=\"" << _library << "\", expected type=" + << plugin_type_to_string(_type) << " (" << static_cast(_type) << "), expected version=" << _version + << ". Returning nullptr." << std::endl; return nullptr; } std::shared_ptr plugin_manager_impl::load_static_plugin(plugin_type_e _type, uint32_t _version) { std::lock_guard its_lock_start_stop(plugins_mutex_); + std::cerr << "[vsomeip][plugin-debug] Looking for registered static plugin factory for type=" << plugin_type_to_string(_type) + << " (" << static_cast(_type) << "), expected version=" << _version << "." << std::endl; auto its_factory = static_factories_.find(_type); if (its_factory == static_factories_.end()) { + std::cerr << "[vsomeip][plugin-debug] No static plugin factory registered for type=" << plugin_type_to_string(_type) + << ". For the configuration plugin, this usually means the object containing register_static_plugin was not linked " + "or its static registrar did not run." + << std::endl; return nullptr; } auto its_create_func = its_factory->second; if (!its_create_func) { + std::cerr << "[vsomeip][plugin-debug] Static plugin factory entry exists for type=" << plugin_type_to_string(_type) + << " but the factory function pointer is nullptr." << std::endl; return nullptr; } auto its_plugin = (*its_create_func)(); if (its_plugin && its_plugin->get_plugin_type() == _type && its_plugin->get_plugin_version() == _version) { + std::cerr << "[vsomeip][plugin-debug] Static plugin factory created matching plugin: name=\"" + << its_plugin->get_plugin_name() << "\", type=" << plugin_type_to_string(its_plugin->get_plugin_type()) << " (" + << static_cast(its_plugin->get_plugin_type()) << "), version=" << its_plugin->get_plugin_version() << "." + << std::endl; return its_plugin; } if (its_plugin) { + std::cerr << "[vsomeip][plugin-debug] Static plugin factory created a plugin with wrong type/version: name=\"" + << its_plugin->get_plugin_name() << "\", expected type=" << plugin_type_to_string(_type) << " (" + << static_cast(_type) << "), expected version=" << _version << "; got type=" + << plugin_type_to_string(its_plugin->get_plugin_type()) << " (" + << static_cast(its_plugin->get_plugin_type()) << "), got version=" << its_plugin->get_plugin_version() << "." + << std::endl; VSOMEIP_ERROR << "Plugin version mismatch. Ignoring static plugin " << its_plugin->get_plugin_name(); + } else { + std::cerr << "[vsomeip][plugin-debug] Static plugin factory returned nullptr for type=" << plugin_type_to_string(_type) + << "." << std::endl; } return nullptr; } @@ -130,21 +217,40 @@ bool plugin_manager_impl::unload_plugin(plugin_type_e _type) { } void plugin_manager_impl::add_plugin(const std::shared_ptr& _plugin, const std::string& _name) { + std::cerr << "[vsomeip][plugin-debug] add_plugin storing plugin name=\"" << _name << "\", plugin_name=\"" + << _plugin->get_plugin_name() << "\", type=" << plugin_type_to_string(_plugin->get_plugin_type()) << " (" + << static_cast(_plugin->get_plugin_type()) << "), version=" << _plugin->get_plugin_version() << "." + << std::endl; plugins_[_plugin->get_plugin_type()][_name] = _plugin; } void plugin_manager_impl::register_static_plugin(plugin_type_e _type, create_plugin_func _factory) { std::lock_guard its_lock_start_stop(plugins_mutex_); + std::cerr << "[vsomeip][plugin-debug] register_static_plugin called for type=" << plugin_type_to_string(_type) << " (" + << static_cast(_type) << "), factory=" << (_factory ? "set" : "nullptr") << "." << std::endl; static_factories_[_type] = _factory; } void* plugin_manager_impl::load_library(const std::string& _path) { + std::cerr << "[vsomeip][plugin-debug] Attempting to load dynamic plugin library \"" << _path << "\"." << std::endl; #ifdef _WIN32 - return LoadLibrary(_path.c_str()); + void* handle = LoadLibrary(_path.c_str()); + if (handle == nullptr) { + std::cerr << "[vsomeip][plugin-debug] LoadLibrary failed for \"" << _path << "\" with error code " << GetLastError() + << "." << std::endl; + } else { + std::cerr << "[vsomeip][plugin-debug] LoadLibrary succeeded for \"" << _path << "\"." << std::endl; + } + return handle; #else void* handle = dlopen(_path.c_str(), RTLD_LAZY | RTLD_LOCAL); if (handle == nullptr) { - VSOMEIP_ERROR << "Could not dlopen \"" << _path << "\" due to err: " << dlerror(); + const char* its_error = dlerror(); + std::cerr << "[vsomeip][plugin-debug] dlopen failed for \"" << _path << "\" due to: " + << (its_error ? its_error : "") << "." << std::endl; + VSOMEIP_ERROR << "Could not dlopen \"" << _path << "\" due to err: " << (its_error ? its_error : ""); + } else { + std::cerr << "[vsomeip][plugin-debug] dlopen succeeded for \"" << _path << "\"." << std::endl; } return handle; @@ -154,6 +260,8 @@ void* plugin_manager_impl::load_library(const std::string& _path) { void* plugin_manager_impl::load_symbol(void* _handle, const std::string& _symbol_name) { void* symbol = nullptr; if (_handle) { + std::cerr << "[vsomeip][plugin-debug] Attempting to load symbol \"" << _symbol_name << "\" from dynamic plugin handle." + << std::endl; #ifdef _WIN32 symbol = GetProcAddress(reinterpret_cast(_handle), _symbol_name.c_str()); #else @@ -176,12 +284,20 @@ void* plugin_manager_impl::load_symbol(void* _handle, const std::string& _symbol #else VSOMEIP_ERROR << "Cannot load symbol " << std::quoted(_symbol_name) << " because: " << error_message; #endif + std::cerr << "[vsomeip][plugin-debug] Loading symbol \"" << _symbol_name + << "\" failed because: " << (error_message ? error_message : "") << "." + << std::endl; #ifdef _WIN32 // Required to release memory allocated by FormatMessageA() LocalFree(error_message); #endif + } else { + std::cerr << "[vsomeip][plugin-debug] Loading symbol \"" << _symbol_name << "\" succeeded." << std::endl; } + } else { + std::cerr << "[vsomeip][plugin-debug] Skipping symbol lookup for \"" << _symbol_name + << "\" because the dynamic library handle is nullptr." << std::endl; } return symbol; } diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index f48ade4ea..4e70730a4 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -165,24 +165,45 @@ bool application_impl::init() { std::string config_module = ""; const char* its_config_module = getenv(VSOMEIP_ENV_CONFIGURATION_MODULE); if (nullptr != its_config_module) { + std::cerr << "[vsomeip][configuration-debug] Environment variable " << VSOMEIP_ENV_CONFIGURATION_MODULE << " is set to \"" + << its_config_module << "\". Custom configuration module loading is currently not implemented in this path." + << std::endl; // TODO: Add loading of custom configuration module } else { // load default module + std::cerr << "[vsomeip][configuration-debug] Environment variable " << VSOMEIP_ENV_CONFIGURATION_MODULE + << " is not set. Trying to load the default configuration plugin \"" << VSOMEIP_CFG_LIBRARY << "\"." + << std::endl; #ifndef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS auto its_plugin = plugin_manager::get()->get_plugin(plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY); if (its_plugin) { + std::cerr << "[vsomeip][configuration-debug] Plugin manager returned a plugin for \"" << VSOMEIP_CFG_LIBRARY + << "\". Verifying that it implements configuration_plugin." << std::endl; auto its_configuration_plugin = std::dynamic_pointer_cast(its_plugin); if (its_configuration_plugin) { + std::cerr << "[vsomeip][configuration-debug] Configuration plugin cast succeeded. Loading configuration for application \"" + << name_ << "\" with configuration path \"" << path_ << "\"." << std::endl; configuration_ = its_configuration_plugin->get_configuration(name_, path_); VSOMEIP_INFO << "Configuration module loaded."; } else { + std::cerr << "[vsomeip][configuration-debug] Plugin manager returned a plugin, but dynamic_pointer_cast " + "failed. The plugin has an unexpected concrete type." + << std::endl; std::cerr << "Invalid configuration module!" << std::endl; std::exit(EXIT_FAILURE); } } else { + std::cerr << "[vsomeip][configuration-debug] Plugin manager returned nullptr for the default configuration plugin \"" + << VSOMEIP_CFG_LIBRARY + << "\". This means no valid static configuration plugin was registered/created and no valid dynamic plugin " + "could be loaded from that library name." + << std::endl; std::cerr << "1 Configuration module could not be loaded!" << std::endl; std::exit(EXIT_FAILURE); } #else + std::cerr << "[vsomeip][configuration-debug] VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS is enabled. Bypassing the configuration " + "plugin manager and constructing cfg::configuration_impl directly." + << std::endl; configuration_ = std::dynamic_pointer_cast(std::make_shared(configuration_path)); if (configuration_path.length()) { From 63ad2d88b16812c3bee95c4b012a84d830b39902 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 09:14:04 +0200 Subject: [PATCH 02/14] Force static build of plugins --- BUILD | 32 ++--- .../src/configuration_plugin_impl.cpp | 8 +- .../plugin/src/plugin_manager_impl.cpp | 133 ++---------------- .../service_discovery/src/runtime_impl.cpp | 6 +- 4 files changed, 29 insertions(+), 150 deletions(-) diff --git a/BUILD b/BUILD index 95bc9f1ed..0ac50f7c6 100644 --- a/BUILD +++ b/BUILD @@ -6,13 +6,14 @@ cc_shared_library( #user_link_flags = [ # "-Wl,--no-undefined", #], - deps = ["//implementation"], + deps = [ + "//implementation:configuration", + "//implementation:service_discovery", + ], ) -cc_shared_library( +cc_library( name = "vsomeip3_config_plugin", - dynamic_deps = [":vsomeip3_shared"], - shared_lib_name = "libvsomeip3-cfg.so.3", tags = ["same-ros-pkg-as: vsomeip3"], # Disabled due to linking problem when used as an external repository with sanitizers enabled. #user_link_flags = [ @@ -21,10 +22,8 @@ cc_shared_library( deps = ["//implementation:configuration"], ) -cc_shared_library( +cc_library( name = "vsomeip3_sd_plugin", - dynamic_deps = [":vsomeip3_shared"], - shared_lib_name = "libvsomeip3-sd.so.3", tags = ["same-ros-pkg-as: vsomeip3"], # Disabled due to linking problem when used as an external repository with sanitizers enabled. #user_link_flags = [ @@ -40,25 +39,10 @@ cc_import( deps = ["//interface"], ) -cc_import( - name = "vsomeip3_configuration_plugin_import", - shared_library = ":vsomeip3_config_plugin", - tags = ["same-ros-pkg-as: vsomeip3"], -) - -cc_import( - name = "vsomeip3_sd_plugin_import", - shared_library = ":vsomeip3_sd_plugin", - tags = ["same-ros-pkg-as: vsomeip3"], -) # interface library, use this target to depend on vsomeip cc_library( name = "vsomeip3", - data = [ - ":vsomeip3_config_plugin", - ":vsomeip3_sd_plugin", - ], linkopts = select({ "@platforms//os:linux": ["-lpthread"], "//conditions:default": [], @@ -66,9 +50,9 @@ cc_library( linkstatic = True, # no object files visibility = ["//visibility:public"], deps = [ - ":vsomeip3_configuration_plugin_import", + ":vsomeip3_config_plugin", ":vsomeip3_import", - ":vsomeip3_sd_plugin_import", + ":vsomeip3_sd_plugin", "//interface", ], ) diff --git a/implementation/configuration/src/configuration_plugin_impl.cpp b/implementation/configuration/src/configuration_plugin_impl.cpp index dee195d3b..b3d0fd5df 100644 --- a/implementation/configuration/src/configuration_plugin_impl.cpp +++ b/implementation/configuration/src/configuration_plugin_impl.cpp @@ -47,9 +47,9 @@ bool configuration_plugin_impl::remove_configuration(const std::string& _name) { namespace { -struct configuration_plugin_static_registrar { - configuration_plugin_static_registrar() { - std::cerr << "[vsomeip][configuration-debug] Static configuration plugin registrar is running. Registering " +struct configuration_plugin_static_registration { + configuration_plugin_static_registration() { + std::cerr << "[vsomeip][configuration-debug] Static configuration plugin registration is running. Registering " "CONFIGURATION_PLUGIN factory with plugin_manager." << std::endl; plugin_manager::register_static_plugin(plugin_type_e::CONFIGURATION_PLUGIN, @@ -57,7 +57,7 @@ struct configuration_plugin_static_registrar { } }; -const configuration_plugin_static_registrar configuration_plugin_static_registrar_{}; +const configuration_plugin_static_registration configuration_plugin_static_registration_{}; } // namespace } // namespace vsomeip_v3 diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index ae89544ce..6613334f8 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -102,52 +102,7 @@ std::shared_ptr plugin_manager_impl::load_plugin(const std::string& _lib return its_plugin; } std::cerr << "[vsomeip][plugin-debug] Static plugin lookup failed for type=" << plugin_type_to_string(_type) - << ". Falling back to dynamic library loading for \"" << _library << "\"." << std::endl; - void* handle = load_library(_library); - if (!handle) { - std::cerr << "[vsomeip][plugin-debug] Dynamic library loading returned nullptr for \"" << _library - << "\". No plugin init symbol can be loaded from this library." << std::endl; - } - plugin_init_func its_init_func = reinterpret_cast(load_symbol(handle, VSOMEIP_PLUGIN_INIT_SYMBOL)); - if (its_init_func) { - std::cerr << "[vsomeip][plugin-debug] Found plugin init symbol \"" << VSOMEIP_PLUGIN_INIT_SYMBOL << "\" in \"" << _library - << "\". Calling it to obtain the create_plugin function." << std::endl; - create_plugin_func its_create_func = (*its_init_func)(); - if (its_create_func) { - std::cerr << "[vsomeip][plugin-debug] Plugin init function returned a create_plugin function for \"" << _library - << "\". Creating plugin instance." << std::endl; - handles_[_type][_library] = handle; - auto its_plugin = (*its_create_func)(); - if (its_plugin) { - std::cerr << "[vsomeip][plugin-debug] Dynamic plugin instance created: name=\"" << its_plugin->get_plugin_name() - << "\", type=" << plugin_type_to_string(its_plugin->get_plugin_type()) << " (" - << static_cast(its_plugin->get_plugin_type()) << "), version=" << its_plugin->get_plugin_version() - << "." << std::endl; - if (its_plugin->get_plugin_type() == _type && its_plugin->get_plugin_version() == _version) { - std::cerr << "[vsomeip][plugin-debug] Dynamic plugin type/version match. Adding plugin \"" << _library - << "\" to cache." << std::endl; - add_plugin(its_plugin, _library); - return its_plugin; - } else { - std::cerr << "[vsomeip][plugin-debug] Dynamic plugin type/version mismatch. Expected type=" - << plugin_type_to_string(_type) << " (" << static_cast(_type) << "), version=" << _version - << "; got type=" << plugin_type_to_string(its_plugin->get_plugin_type()) << " (" - << static_cast(its_plugin->get_plugin_type()) << "), version=" - << its_plugin->get_plugin_version() << "." << std::endl; - VSOMEIP_ERROR << "Plugin version mismatch. Ignoring plugin " << its_plugin->get_plugin_name(); - } - } else { - std::cerr << "[vsomeip][plugin-debug] Dynamic create_plugin function returned nullptr for \"" << _library << "\"." - << std::endl; - } - } else { - std::cerr << "[vsomeip][plugin-debug] Plugin init symbol returned a nullptr create_plugin function for \"" << _library - << "\"." << std::endl; - } - } else { - std::cerr << "[vsomeip][plugin-debug] Plugin init symbol \"" << VSOMEIP_PLUGIN_INIT_SYMBOL << "\" was not available for \"" - << _library << "\"." << std::endl; - } + << ". Shared-library plugin loading is disabled, so \"" << _library << "\" will not be dlopen'ed." << std::endl; std::cerr << "[vsomeip][plugin-debug] load_plugin failed for library=\"" << _library << "\", expected type=" << plugin_type_to_string(_type) << " (" << static_cast(_type) << "), expected version=" << _version << ". Returning nullptr." << std::endl; @@ -162,7 +117,7 @@ std::shared_ptr plugin_manager_impl::load_static_plugin(plugin_type_e _t if (its_factory == static_factories_.end()) { std::cerr << "[vsomeip][plugin-debug] No static plugin factory registered for type=" << plugin_type_to_string(_type) << ". For the configuration plugin, this usually means the object containing register_static_plugin was not linked " - "or its static registrar did not run." + "or its static registration did not run." << std::endl; return nullptr; } @@ -200,6 +155,9 @@ bool plugin_manager_impl::unload_plugin(plugin_type_e _type) { const auto found_handle = handles_.find(_type); if (found_handle != handles_.end()) { for (const auto& its_name : found_handle->second) { + if (!its_name.second) { + continue; + } #ifdef _WIN32 FreeLibrary((HMODULE)its_name.second); #else @@ -232,84 +190,21 @@ void plugin_manager_impl::register_static_plugin(plugin_type_e _type, create_plu } void* plugin_manager_impl::load_library(const std::string& _path) { - std::cerr << "[vsomeip][plugin-debug] Attempting to load dynamic plugin library \"" << _path << "\"." << std::endl; -#ifdef _WIN32 - void* handle = LoadLibrary(_path.c_str()); - if (handle == nullptr) { - std::cerr << "[vsomeip][plugin-debug] LoadLibrary failed for \"" << _path << "\" with error code " << GetLastError() - << "." << std::endl; - } else { - std::cerr << "[vsomeip][plugin-debug] LoadLibrary succeeded for \"" << _path << "\"." << std::endl; - } - return handle; -#else - void* handle = dlopen(_path.c_str(), RTLD_LAZY | RTLD_LOCAL); - if (handle == nullptr) { - const char* its_error = dlerror(); - std::cerr << "[vsomeip][plugin-debug] dlopen failed for \"" << _path << "\" due to: " - << (its_error ? its_error : "") << "." << std::endl; - VSOMEIP_ERROR << "Could not dlopen \"" << _path << "\" due to err: " << (its_error ? its_error : ""); - } else { - std::cerr << "[vsomeip][plugin-debug] dlopen succeeded for \"" << _path << "\"." << std::endl; - } - - return handle; -#endif + std::cerr << "[vsomeip][plugin-debug] Shared-library loading is disabled. Refusing to load \"" << _path << "\"." + << std::endl; + return nullptr; } void* plugin_manager_impl::load_symbol(void* _handle, const std::string& _symbol_name) { - void* symbol = nullptr; - if (_handle) { - std::cerr << "[vsomeip][plugin-debug] Attempting to load symbol \"" << _symbol_name << "\" from dynamic plugin handle." - << std::endl; -#ifdef _WIN32 - symbol = GetProcAddress(reinterpret_cast(_handle), _symbol_name.c_str()); -#else - symbol = dlsym(_handle, _symbol_name.c_str()); -#endif - - if (!symbol) { - char* error_message = nullptr; - -#ifdef _WIN32 - DWORD error_code = GetLastError(); - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error_code, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&error_message), 0, nullptr); -#else - error_message = dlerror(); -#endif - -#ifdef __QNX__ - VSOMEIP_ERROR << "Cannot load symbol " << std::quoted(_symbol_name.c_str()) << " because: " << error_message; -#else - VSOMEIP_ERROR << "Cannot load symbol " << std::quoted(_symbol_name) << " because: " << error_message; -#endif - std::cerr << "[vsomeip][plugin-debug] Loading symbol \"" << _symbol_name - << "\" failed because: " << (error_message ? error_message : "") << "." - << std::endl; - -#ifdef _WIN32 - // Required to release memory allocated by FormatMessageA() - LocalFree(error_message); -#endif - } else { - std::cerr << "[vsomeip][plugin-debug] Loading symbol \"" << _symbol_name << "\" succeeded." << std::endl; - } - } else { - std::cerr << "[vsomeip][plugin-debug] Skipping symbol lookup for \"" << _symbol_name - << "\" because the dynamic library handle is nullptr." << std::endl; - } - return symbol; + (void)_handle; + std::cerr << "[vsomeip][plugin-debug] Shared-library loading is disabled. Refusing to load symbol \"" << _symbol_name + << "\"." << std::endl; + return nullptr; } void plugin_manager_impl::unload_library(void* _handle) { - if (_handle) { -#ifdef _WIN32 - FreeLibrary(reinterpret_cast(_handle)); -#else - dlclose(_handle); -#endif - } + (void)_handle; + std::cerr << "[vsomeip][plugin-debug] Shared-library loading is disabled. Ignoring unload_library request." << std::endl; } } // namespace vsomeip_v3 diff --git a/implementation/service_discovery/src/runtime_impl.cpp b/implementation/service_discovery/src/runtime_impl.cpp index c1e9e438b..2898c3b33 100644 --- a/implementation/service_discovery/src/runtime_impl.cpp +++ b/implementation/service_discovery/src/runtime_impl.cpp @@ -30,13 +30,13 @@ std::shared_ptr runtime_impl::create_service_discovery(servic namespace { -struct sd_plugin_registrar { - sd_plugin_registrar() { +struct sd_plugin_registration { + sd_plugin_registration() { plugin_manager::register_static_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, sd::runtime_impl::get_plugin); } }; -const sd_plugin_registrar sd_plugin_registrar_{}; +const sd_plugin_registration sd_plugin_registration_{}; } // namespace From 56a67232b676521a410f05542f2b76fe02ea3277 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 09:16:36 +0200 Subject: [PATCH 03/14] force staitc 2 --- implementation/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/BUILD b/implementation/BUILD index 56fbd56fc..e512a7db0 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -1,7 +1,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-debug1" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-2" # Must match the git tag version. expand_template( name = "config", From 7137acca28bf4cb73407b05daef6b4b28ac476ce Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 10:07:43 +0200 Subject: [PATCH 04/14] force static 3 --- implementation/BUILD | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/implementation/BUILD b/implementation/BUILD index e512a7db0..ca4c0b759 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -1,7 +1,8 @@ load("//bazel:expand_template.bzl", "expand_template") +load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-2" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-3" # Must match the git tag version. expand_template( name = "config", @@ -24,13 +25,13 @@ expand_template( template = "configuration/include/internal.hpp.in", ) -cc_library( +apex_cc_library( name = "generated_config", hdrs = [":config"], strip_include_prefix = "configuration/include", ) -cc_library( +apex_cc_library( name = "helper", hdrs = glob( [ @@ -49,7 +50,7 @@ cc_library( ], ) -cc_library( +apex_cc_library( name = "configuration", srcs = glob( [ @@ -63,7 +64,7 @@ cc_library( ], ) -cc_library( +apex_cc_library( name = "service_discovery", srcs = glob( [ @@ -76,7 +77,7 @@ cc_library( ], ) -cc_library( +apex_cc_library( name = "implementation", srcs = glob( [ From aefb9ce0a42567790128dbdaf3387f996c92dbc7 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 10:34:55 +0200 Subject: [PATCH 05/14] force static 4 --- BUILD | 48 +++++++++++++++++++++++--------------------- implementation/BUILD | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/BUILD b/BUILD index 0ac50f7c6..ec2e10563 100644 --- a/BUILD +++ b/BUILD @@ -1,18 +1,20 @@ -cc_shared_library( - name = "vsomeip3_shared", - shared_lib_name = "libvsomeip3.so", - tags = ["same-ros-pkg-as: vsomeip3"], - # Disabled due to linking problem when used as an external repository with sanitizers enabled. - #user_link_flags = [ - # "-Wl,--no-undefined", - #], - deps = [ - "//implementation:configuration", - "//implementation:service_discovery", - ], -) +load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") + +# apex_cc_library( +# name = "vsomeip3_shared", +# shared_lib_name = "libvsomeip3.so", +# tags = ["same-ros-pkg-as: vsomeip3"], +# # Disabled due to linking problem when used as an external repository with sanitizers enabled. +# #user_link_flags = [ +# # "-Wl,--no-undefined", +# #], +# deps = [ +# "//implementation:configuration", +# "//implementation:service_discovery", +# ], +# ) -cc_library( +apex_cc_library( name = "vsomeip3_config_plugin", tags = ["same-ros-pkg-as: vsomeip3"], # Disabled due to linking problem when used as an external repository with sanitizers enabled. @@ -22,7 +24,7 @@ cc_library( deps = ["//implementation:configuration"], ) -cc_library( +apex_cc_library( name = "vsomeip3_sd_plugin", tags = ["same-ros-pkg-as: vsomeip3"], # Disabled due to linking problem when used as an external repository with sanitizers enabled. @@ -32,16 +34,16 @@ cc_library( deps = ["//implementation:service_discovery"], ) -cc_import( - name = "vsomeip3_import", - shared_library = ":vsomeip3_shared", - tags = ["same-ros-pkg-as: vsomeip3"], - deps = ["//interface"], -) +# apex_cc_library( +# name = "vsomeip3_import", +# shared_library = ":vsomeip3_shared", +# tags = ["same-ros-pkg-as: vsomeip3"], +# deps = ["//interface"], +# ) # interface library, use this target to depend on vsomeip -cc_library( +apex_cc_library( name = "vsomeip3", linkopts = select({ "@platforms//os:linux": ["-lpthread"], @@ -51,7 +53,7 @@ cc_library( visibility = ["//visibility:public"], deps = [ ":vsomeip3_config_plugin", - ":vsomeip3_import", + # ":vsomeip3_import", ":vsomeip3_sd_plugin", "//interface", ], diff --git a/implementation/BUILD b/implementation/BUILD index ca4c0b759..a271bb82e 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-3" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-4" # Must match the git tag version. expand_template( name = "config", From 3186beb06491ec68926d8262de1c30505a57f581 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 12:09:08 +0200 Subject: [PATCH 06/14] force static 5 --- .../configuration/include/configuration_plugin_impl.hpp | 4 ++++ .../configuration/src/configuration_plugin_impl.cpp | 8 ++++++++ implementation/plugin/src/plugin_manager_impl.cpp | 7 +++++++ implementation/service_discovery/include/runtime_impl.hpp | 4 ++++ implementation/service_discovery/src/runtime_impl.cpp | 5 +++++ 5 files changed, 28 insertions(+) diff --git a/implementation/configuration/include/configuration_plugin_impl.hpp b/implementation/configuration/include/configuration_plugin_impl.hpp index 0973ff5cc..8629c62a5 100644 --- a/implementation/configuration/include/configuration_plugin_impl.hpp +++ b/implementation/configuration/include/configuration_plugin_impl.hpp @@ -14,6 +14,8 @@ #include "configuration_plugin.hpp" namespace vsomeip_v3 { +class plugin_manager_impl; + namespace cfg { class configuration_impl; @@ -33,6 +35,8 @@ class configuration_plugin_impl : public configuration_plugin, public plugin_imp std::map> configurations_; }; +void register_static_configuration_plugin(plugin_manager_impl& _manager); + } // namespace vsomeip_v3 #endif // VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ diff --git a/implementation/configuration/src/configuration_plugin_impl.cpp b/implementation/configuration/src/configuration_plugin_impl.cpp index b3d0fd5df..a1f87a726 100644 --- a/implementation/configuration/src/configuration_plugin_impl.cpp +++ b/implementation/configuration/src/configuration_plugin_impl.cpp @@ -10,6 +10,7 @@ #include "../include/configuration_plugin_impl.hpp" #include "../include/configuration_impl.hpp" +#include "../../plugin/include/plugin_manager_impl.hpp" namespace vsomeip_v3 { @@ -45,6 +46,13 @@ bool configuration_plugin_impl::remove_configuration(const std::string& _name) { return configurations_.erase(_name) > 0; } +void register_static_configuration_plugin(plugin_manager_impl& _manager) { + std::cerr << "[vsomeip][configuration-debug] Explicit configuration plugin registration is running. Registering " + "CONFIGURATION_PLUGIN factory with plugin_manager." + << std::endl; + _manager.register_static_plugin(plugin_type_e::CONFIGURATION_PLUGIN, configuration_plugin_impl::get_plugin); +} + namespace { struct configuration_plugin_static_registration { diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index 6613334f8..c689ac35d 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -21,6 +21,8 @@ #include #include +#include "../../configuration/include/configuration_plugin_impl.hpp" +#include "../../service_discovery/include/runtime_impl.hpp" #include "../include/plugin_manager_impl.hpp" #ifdef ANDROID @@ -56,9 +58,14 @@ const char* plugin_type_to_string(plugin_type_e _type) { std::shared_ptr plugin_manager_impl::get() { static std::once_flag initialization_flag; + static std::once_flag builtin_plugin_registration_flag; std::call_once(initialization_flag, []() { the_plugin_manager__ = std::make_shared(); }); + std::call_once(builtin_plugin_registration_flag, []() { + register_static_configuration_plugin(*the_plugin_manager__); + sd::register_static_sd_runtime_plugin(*the_plugin_manager__); + }); return the_plugin_manager__; } diff --git a/implementation/service_discovery/include/runtime_impl.hpp b/implementation/service_discovery/include/runtime_impl.hpp index 0b6534751..1d933e253 100644 --- a/implementation/service_discovery/include/runtime_impl.hpp +++ b/implementation/service_discovery/include/runtime_impl.hpp @@ -10,6 +10,8 @@ #include "runtime.hpp" namespace vsomeip_v3 { +class plugin_manager_impl; + namespace sd { class runtime_impl : public runtime, public plugin_impl { @@ -21,6 +23,8 @@ class runtime_impl : public runtime, public plugin_impl { std::shared_ptr _configuration) const; }; +void register_static_sd_runtime_plugin(plugin_manager_impl& _manager); + } // namespace sd } // namespace vsomeip_v3 diff --git a/implementation/service_discovery/src/runtime_impl.cpp b/implementation/service_discovery/src/runtime_impl.cpp index 2898c3b33..f37242784 100644 --- a/implementation/service_discovery/src/runtime_impl.cpp +++ b/implementation/service_discovery/src/runtime_impl.cpp @@ -7,6 +7,7 @@ #include #include +#include "../../plugin/include/plugin_manager_impl.hpp" #include "../include/constants.hpp" #include "../include/defines.hpp" #include "../include/message_impl.hpp" @@ -26,6 +27,10 @@ std::shared_ptr runtime_impl::create_service_discovery(servic return std::make_shared(_host, _configuration); } +void register_static_sd_runtime_plugin(plugin_manager_impl& _manager) { + _manager.register_static_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, runtime_impl::get_plugin); +} + } // namespace sd namespace { From cd8c29a56d7ee3b241a97d090368f1302c2afa8d Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 12:12:06 +0200 Subject: [PATCH 07/14] force static 6 --- implementation/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/BUILD b/implementation/BUILD index a271bb82e..3632dc614 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-4" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-6" # Must match the git tag version. expand_template( name = "config", From 99f227f41f127ae2a3213272d3c886b2a2d8269b Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 12:15:28 +0200 Subject: [PATCH 08/14] force static 7 --- implementation/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/BUILD b/implementation/BUILD index 3632dc614..3cdede062 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-6" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-7" # Must match the git tag version. expand_template( name = "config", From d4d9ed9e3177a9ac6c99e672c62ee79e431348cd Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 12:36:37 +0200 Subject: [PATCH 09/14] force static 8 --- BUILD | 13 +++++++++++++ implementation/BUILD | 2 +- .../include/configuration_plugin_impl.hpp | 4 ---- .../configuration/src/configuration_plugin_impl.cpp | 8 -------- implementation/plugin/src/plugin_manager_impl.cpp | 7 ------- .../service_discovery/include/runtime_impl.hpp | 4 ---- .../service_discovery/src/runtime_impl.cpp | 5 ----- 7 files changed, 14 insertions(+), 29 deletions(-) diff --git a/BUILD b/BUILD index ec2e10563..7f69425aa 100644 --- a/BUILD +++ b/BUILD @@ -43,6 +43,18 @@ apex_cc_library( # interface library, use this target to depend on vsomeip +apex_cc_library( + name = "vsomeip3_builtin_plugins", + srcs = ["src/plugin_init.cpp"], + alwayslink = True, + visibility = ["//visibility:private"], + deps = [ + ":vsomeip3_config_plugin", + ":vsomeip3_sd_plugin", + "//interface", + ], +) + apex_cc_library( name = "vsomeip3", linkopts = select({ @@ -52,6 +64,7 @@ apex_cc_library( linkstatic = True, # no object files visibility = ["//visibility:public"], deps = [ + ":vsomeip3_builtin_plugins", ":vsomeip3_config_plugin", # ":vsomeip3_import", ":vsomeip3_sd_plugin", diff --git a/implementation/BUILD b/implementation/BUILD index 3cdede062..af4c496ca 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-7" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-8" # Must match the git tag version. expand_template( name = "config", diff --git a/implementation/configuration/include/configuration_plugin_impl.hpp b/implementation/configuration/include/configuration_plugin_impl.hpp index 8629c62a5..0973ff5cc 100644 --- a/implementation/configuration/include/configuration_plugin_impl.hpp +++ b/implementation/configuration/include/configuration_plugin_impl.hpp @@ -14,8 +14,6 @@ #include "configuration_plugin.hpp" namespace vsomeip_v3 { -class plugin_manager_impl; - namespace cfg { class configuration_impl; @@ -35,8 +33,6 @@ class configuration_plugin_impl : public configuration_plugin, public plugin_imp std::map> configurations_; }; -void register_static_configuration_plugin(plugin_manager_impl& _manager); - } // namespace vsomeip_v3 #endif // VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ diff --git a/implementation/configuration/src/configuration_plugin_impl.cpp b/implementation/configuration/src/configuration_plugin_impl.cpp index a1f87a726..b3d0fd5df 100644 --- a/implementation/configuration/src/configuration_plugin_impl.cpp +++ b/implementation/configuration/src/configuration_plugin_impl.cpp @@ -10,7 +10,6 @@ #include "../include/configuration_plugin_impl.hpp" #include "../include/configuration_impl.hpp" -#include "../../plugin/include/plugin_manager_impl.hpp" namespace vsomeip_v3 { @@ -46,13 +45,6 @@ bool configuration_plugin_impl::remove_configuration(const std::string& _name) { return configurations_.erase(_name) > 0; } -void register_static_configuration_plugin(plugin_manager_impl& _manager) { - std::cerr << "[vsomeip][configuration-debug] Explicit configuration plugin registration is running. Registering " - "CONFIGURATION_PLUGIN factory with plugin_manager." - << std::endl; - _manager.register_static_plugin(plugin_type_e::CONFIGURATION_PLUGIN, configuration_plugin_impl::get_plugin); -} - namespace { struct configuration_plugin_static_registration { diff --git a/implementation/plugin/src/plugin_manager_impl.cpp b/implementation/plugin/src/plugin_manager_impl.cpp index c689ac35d..6613334f8 100644 --- a/implementation/plugin/src/plugin_manager_impl.cpp +++ b/implementation/plugin/src/plugin_manager_impl.cpp @@ -21,8 +21,6 @@ #include #include -#include "../../configuration/include/configuration_plugin_impl.hpp" -#include "../../service_discovery/include/runtime_impl.hpp" #include "../include/plugin_manager_impl.hpp" #ifdef ANDROID @@ -58,14 +56,9 @@ const char* plugin_type_to_string(plugin_type_e _type) { std::shared_ptr plugin_manager_impl::get() { static std::once_flag initialization_flag; - static std::once_flag builtin_plugin_registration_flag; std::call_once(initialization_flag, []() { the_plugin_manager__ = std::make_shared(); }); - std::call_once(builtin_plugin_registration_flag, []() { - register_static_configuration_plugin(*the_plugin_manager__); - sd::register_static_sd_runtime_plugin(*the_plugin_manager__); - }); return the_plugin_manager__; } diff --git a/implementation/service_discovery/include/runtime_impl.hpp b/implementation/service_discovery/include/runtime_impl.hpp index 1d933e253..0b6534751 100644 --- a/implementation/service_discovery/include/runtime_impl.hpp +++ b/implementation/service_discovery/include/runtime_impl.hpp @@ -10,8 +10,6 @@ #include "runtime.hpp" namespace vsomeip_v3 { -class plugin_manager_impl; - namespace sd { class runtime_impl : public runtime, public plugin_impl { @@ -23,8 +21,6 @@ class runtime_impl : public runtime, public plugin_impl { std::shared_ptr _configuration) const; }; -void register_static_sd_runtime_plugin(plugin_manager_impl& _manager); - } // namespace sd } // namespace vsomeip_v3 diff --git a/implementation/service_discovery/src/runtime_impl.cpp b/implementation/service_discovery/src/runtime_impl.cpp index f37242784..2898c3b33 100644 --- a/implementation/service_discovery/src/runtime_impl.cpp +++ b/implementation/service_discovery/src/runtime_impl.cpp @@ -7,7 +7,6 @@ #include #include -#include "../../plugin/include/plugin_manager_impl.hpp" #include "../include/constants.hpp" #include "../include/defines.hpp" #include "../include/message_impl.hpp" @@ -27,10 +26,6 @@ std::shared_ptr runtime_impl::create_service_discovery(servic return std::make_shared(_host, _configuration); } -void register_static_sd_runtime_plugin(plugin_manager_impl& _manager) { - _manager.register_static_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, runtime_impl::get_plugin); -} - } // namespace sd namespace { From 5dac6bc5ffd747ce89d817e9a1be356ef3739dd6 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 13:36:48 +0200 Subject: [PATCH 10/14] force static 9 --- src/plugin_init.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/plugin_init.cpp diff --git a/src/plugin_init.cpp b/src/plugin_init.cpp new file mode 100644 index 000000000..907e08082 --- /dev/null +++ b/src/plugin_init.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2024 Apex.AI, Inc. + +#include + +#include + +#include "../implementation/configuration/include/configuration_plugin_impl.hpp" +#include "../implementation/service_discovery/include/runtime_impl.hpp" + +namespace vsomeip_v3 { +namespace { + +void initialize_builtin_plugins() { + static std::once_flag registration_flag; + std::call_once(registration_flag, []() { + plugin_manager::register_static_plugin(plugin_type_e::CONFIGURATION_PLUGIN, + configuration_plugin_impl::get_plugin); + plugin_manager::register_static_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, + sd::runtime_impl::get_plugin); + }); +} + +struct builtin_plugin_initializer { + builtin_plugin_initializer() { + initialize_builtin_plugins(); + } +}; + +const builtin_plugin_initializer builtin_plugin_initializer_{}; + +} // namespace +} // namespace vsomeip_v3 From 95500b1925e5f00099d999001b3c98f07b8c2bda Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Fri, 8 May 2026 13:37:27 +0200 Subject: [PATCH 11/14] force static 10 --- .github/workflows/upload-apex-release-on-tag.yml | 2 +- implementation/BUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload-apex-release-on-tag.yml b/.github/workflows/upload-apex-release-on-tag.yml index 5adc1d0eb..aaa3dcec3 100644 --- a/.github/workflows/upload-apex-release-on-tag.yml +++ b/.github/workflows/upload-apex-release-on-tag.yml @@ -45,7 +45,7 @@ jobs: with: tag_name: ${{ github.ref_name }} files: /tmp/${{ github.ref_name }}.tar.gz - draft: true + draft: false prerelease: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/implementation/BUILD b/implementation/BUILD index af4c496ca..66ba4601f 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-8" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-10" # Must match the git tag version. expand_template( name = "config", From 407f809c374ed55dd7a3d58b0f70e45c8800ca21 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Tue, 12 May 2026 10:44:09 +0200 Subject: [PATCH 12/14] fix gateway comm --- implementation/BUILD | 2 +- .../local_server_endpoint_impl_receive_op.hpp | 8 +++++++- .../include/local_tcp_client_endpoint_impl.hpp | 3 +++ .../include/local_uds_client_endpoint_impl.hpp | 3 +++ .../src/local_tcp_client_endpoint_impl.cpp | 18 +++++++++++++++--- .../src/local_uds_client_endpoint_impl.cpp | 18 +++++++++++++++--- 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/implementation/BUILD b/implementation/BUILD index 66ba4601f..3f70f116d 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-force-static-10" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-fix-qnx-gateway-com-00" # Must match the git tag version. expand_template( name = "config", diff --git a/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp b/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp index 10c80365a..a370a586d 100644 --- a/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/local_server_endpoint_impl_receive_op.hpp @@ -8,7 +8,13 @@ #if defined(__linux__) || defined(__QNX__) +#include +#include +#include +#include + #include +#include #include namespace vsomeip_v3 { @@ -36,7 +42,7 @@ inline std::function receive_cb(std::sha if (!_error) { if (!_data->socket_.native_non_blocking()) _data->socket_.native_non_blocking(true, _error); -#if defined(__linux__) +#if defined(__linux__) || defined(__QNX__) for (;;) { ssize_t its_result; int its_flags(0); diff --git a/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp index 382ace37d..476926b47 100644 --- a/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp @@ -6,6 +6,8 @@ #ifndef VSOMEIP_V3_LOCAL_TCP_CLIENT_ENDPOINT_IMPL_HPP_ #define VSOMEIP_V3_LOCAL_TCP_CLIENT_ENDPOINT_IMPL_HPP_ +#include + #include #include @@ -56,6 +58,7 @@ class local_tcp_client_endpoint_impl : public local_tcp_client_endpoint_base_imp void max_allowed_reconnects_reached(); message_buffer_t recv_buffer_; + std::size_t recv_buffer_size_; // send data message_buffer_ptr_t send_data_buffer_; diff --git a/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp b/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp index 6129d54b9..cf111723d 100644 --- a/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp @@ -6,6 +6,8 @@ #ifndef VSOMEIP_V3_LOCAL_UDS_CLIENT_ENDPOINT_IMPL_HPP_ #define VSOMEIP_V3_LOCAL_UDS_CLIENT_ENDPOINT_IMPL_HPP_ +#include + #include #include @@ -55,6 +57,7 @@ class local_uds_client_endpoint_impl : public local_uds_client_endpoint_base_imp void max_allowed_reconnects_reached(); message_buffer_t recv_buffer_; + std::size_t recv_buffer_size_; // send data message_buffer_ptr_t send_data_buffer_; diff --git a/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp index 08e9263ef..05ebdb3eb 100644 --- a/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp @@ -33,7 +33,7 @@ local_tcp_client_endpoint_impl::local_tcp_client_endpoint_impl(const std::shared boost::asio::io_context& _io, const std::shared_ptr& _configuration) : local_tcp_client_endpoint_base_impl(_endpoint_host, _routing_host, _local, _remote, _io, _configuration), - recv_buffer_(VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE, 0) { + recv_buffer_(VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE, 0), recv_buffer_size_(0) { this->max_message_size_ = _configuration->get_max_message_size_local(); this->queue_limit_ = _configuration->get_endpoint_queue_limit_local(); @@ -60,6 +60,7 @@ void local_tcp_client_endpoint_impl::restart(bool _force) { queue_.clear(); queue_size_ = 0; is_sending_ = false; + recv_buffer_size_ = 0; } { std::lock_guard its_lock(socket_mutex_); @@ -230,7 +231,11 @@ void local_tcp_client_endpoint_impl::connect() { void local_tcp_client_endpoint_impl::receive() { std::lock_guard its_lock(socket_mutex_); if (socket_->is_open()) { - socket_->async_receive(boost::asio::buffer(recv_buffer_), + if (recv_buffer_size_ == recv_buffer_.size()) { + VSOMEIP_WARNING << "ltcei::" << __func__ << ": receive buffer full before receive endpoint > " << this; + recv_buffer_size_ = 0; + } + socket_->async_receive(boost::asio::buffer(&recv_buffer_[recv_buffer_size_], recv_buffer_.size() - recv_buffer_size_), strand_.wrap(std::bind(&local_tcp_client_endpoint_impl::receive_cbk, std::dynamic_pointer_cast(shared_from_this()), std::placeholders::_1, std::placeholders::_2))); @@ -317,6 +322,7 @@ void local_tcp_client_endpoint_impl::receive_cbk(boost::system::error_code const sending_blocked_ = false; queue_.clear(); queue_size_ = 0; + recv_buffer_size_ = 0; if (is_stopping_) { queue_cv_.notify_all(); @@ -334,16 +340,22 @@ void local_tcp_client_endpoint_impl::receive_cbk(boost::system::error_code const VSOMEIP_INFO << msg.str(); #endif + recv_buffer_size_ += _bytes; + // We only handle a single message here. Check whether the message // format matches what we do expect. // TODO: Replace the magic numbers. - if (_bytes == VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE && recv_buffer_[0] == 0x67 && recv_buffer_[1] == 0x37 + if (recv_buffer_size_ == VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE && recv_buffer_[0] == 0x67 && recv_buffer_[1] == 0x37 && recv_buffer_[2] == 0x6d && recv_buffer_[3] == 0x07 && recv_buffer_[4] == byte_t(protocol::id_e::ASSIGN_CLIENT_ACK_ID) && recv_buffer_[15] == 0x07 && recv_buffer_[16] == 0x6d && recv_buffer_[17] == 0x37 && recv_buffer_[18] == 0x67) { auto its_routing_host = routing_host_.lock(); if (its_routing_host) its_routing_host->on_message(&recv_buffer_[4], static_cast(recv_buffer_.size() - 8), this); + recv_buffer_size_ = 0; + } else if (recv_buffer_size_ == VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE) { + VSOMEIP_WARNING << "ltcei::" << __func__ << ": received malformed assign client ack endpoint > " << this; + recv_buffer_size_ = 0; } receive(); diff --git a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp index 8762ab729..f3b06322f 100644 --- a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp @@ -30,7 +30,7 @@ local_uds_client_endpoint_impl::local_uds_client_endpoint_impl(const std::shared local_uds_client_endpoint_base_impl(_endpoint_host, _routing_host, _remote, _remote, _io, _configuration), // Using _remote for the local(!) endpoint is ok, // because we have no bind for local endpoints! - recv_buffer_(VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE, 0) { + recv_buffer_(VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE, 0), recv_buffer_size_(0) { this->max_message_size_ = _configuration->get_max_message_size_local(); this->queue_limit_ = _configuration->get_endpoint_queue_limit_local(); @@ -50,6 +50,7 @@ void local_uds_client_endpoint_impl::restart(bool _force) { queue_.clear(); queue_size_ = 0; is_sending_ = false; + recv_buffer_size_ = 0; } { std::lock_guard its_lock(socket_mutex_); @@ -175,7 +176,11 @@ void local_uds_client_endpoint_impl::connect() { void local_uds_client_endpoint_impl::receive() { std::lock_guard its_lock(socket_mutex_); if (socket_->is_open()) { - socket_->async_receive(boost::asio::buffer(recv_buffer_), + if (recv_buffer_size_ == recv_buffer_.size()) { + VSOMEIP_WARNING << "lucei::" << __func__ << ": receive buffer full before receive | endpoint > " << this; + recv_buffer_size_ = 0; + } + socket_->async_receive(boost::asio::buffer(&recv_buffer_[recv_buffer_size_], recv_buffer_.size() - recv_buffer_size_), strand_.wrap(std::bind(&local_uds_client_endpoint_impl::receive_cbk, std::dynamic_pointer_cast(shared_from_this()), std::placeholders::_1, std::placeholders::_2))); @@ -263,6 +268,7 @@ void local_uds_client_endpoint_impl::receive_cbk(boost::system::error_code const sending_blocked_ = false; queue_.clear(); queue_size_ = 0; + recv_buffer_size_ = 0; } else if (_error == boost::asio::error::bad_descriptor) { restart(true); return; @@ -279,16 +285,22 @@ void local_uds_client_endpoint_impl::receive_cbk(boost::system::error_code const VSOMEIP_INFO << msg.str(); #endif + recv_buffer_size_ += _bytes; + // We only handle a single message here. Check whether the message // format matches what we do expect. // TODO: Replace the magic numbers. - if (_bytes == VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE && recv_buffer_[0] == 0x67 && recv_buffer_[1] == 0x37 + if (recv_buffer_size_ == VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE && recv_buffer_[0] == 0x67 && recv_buffer_[1] == 0x37 && recv_buffer_[2] == 0x6d && recv_buffer_[3] == 0x07 && recv_buffer_[4] == byte_t(protocol::id_e::ASSIGN_CLIENT_ACK_ID) && recv_buffer_[15] == 0x07 && recv_buffer_[16] == 0x6d && recv_buffer_[17] == 0x37 && recv_buffer_[18] == 0x67) { auto its_routing_host = routing_host_.lock(); if (its_routing_host) its_routing_host->on_message(&recv_buffer_[4], static_cast(recv_buffer_.size() - 8), this); + recv_buffer_size_ = 0; + } else if (recv_buffer_size_ == VSOMEIP_LOCAL_CLIENT_ENDPOINT_RECV_BUFFER_SIZE) { + VSOMEIP_WARNING << "lucei::" << __func__ << ": received malformed assign client ack | endpoint > " << this; + recv_buffer_size_ = 0; } receive(); From a13d91e75bb5ad5b565f91db6d86c467dfe4c839 Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Mon, 18 May 2026 13:27:00 +0200 Subject: [PATCH 13/14] Fix static init again --- BUILD | 13 +------------ src/plugin_init.cpp | 2 ++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/BUILD b/BUILD index 7f69425aa..e72ac7b8d 100644 --- a/BUILD +++ b/BUILD @@ -44,19 +44,9 @@ apex_cc_library( # interface library, use this target to depend on vsomeip apex_cc_library( - name = "vsomeip3_builtin_plugins", + name = "vsomeip3", srcs = ["src/plugin_init.cpp"], alwayslink = True, - visibility = ["//visibility:private"], - deps = [ - ":vsomeip3_config_plugin", - ":vsomeip3_sd_plugin", - "//interface", - ], -) - -apex_cc_library( - name = "vsomeip3", linkopts = select({ "@platforms//os:linux": ["-lpthread"], "//conditions:default": [], @@ -64,7 +54,6 @@ apex_cc_library( linkstatic = True, # no object files visibility = ["//visibility:public"], deps = [ - ":vsomeip3_builtin_plugins", ":vsomeip3_config_plugin", # ":vsomeip3_import", ":vsomeip3_sd_plugin", diff --git a/src/plugin_init.cpp b/src/plugin_init.cpp index 907e08082..bd11ad2a0 100644 --- a/src/plugin_init.cpp +++ b/src/plugin_init.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2024 Apex.AI, Inc. #include +#include #include @@ -13,6 +14,7 @@ namespace { void initialize_builtin_plugins() { static std::once_flag registration_flag; std::call_once(registration_flag, []() { + std::cerr << "[vsomeip][plugin-debug] Explicit builtin plugin initialization is running." << std::endl; plugin_manager::register_static_plugin(plugin_type_e::CONFIGURATION_PLUGIN, configuration_plugin_impl::get_plugin); plugin_manager::register_static_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, From cf5eee29514de1a0c297c7c97469cd5c9b3662dd Mon Sep 17 00:00:00 2001 From: "vincenzo.comito" Date: Mon, 18 May 2026 13:30:29 +0200 Subject: [PATCH 14/14] fix static again 2 --- implementation/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/BUILD b/implementation/BUILD index 3f70f116d..9d1df7ded 100644 --- a/implementation/BUILD +++ b/implementation/BUILD @@ -2,7 +2,7 @@ load("//bazel:expand_template.bzl", "expand_template") load("@apex//common/bazel/rules_cc:defs.bzl", "apex_cc_library") load("@vsomeip//bazel:version.bzl", "version_dict_from_string") -APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-fix-qnx-gateway-com-00" # Must match the git tag version. +APEX_VSOMEIP_VERSION_TAG = "3.6.1-apex8-fix-qnx-gateway-com-02" # Must match the git tag version. expand_template( name = "config",