Skip to content

routing: Guard the Service Discovery runtime cast - #1073

Open
pgajdzis-volvo wants to merge 1 commit into
COVESA:masterfrom
pgajdzis-volvo:fix_runtime
Open

pgajdzis-volvo wants to merge 1 commit into
COVESA:masterfrom
pgajdzis-volvo:fix_runtime

Conversation

@pgajdzis-volvo

Copy link
Copy Markdown

routing_manager_impl::init() dereferenced the result of dynamic_pointer_castsd::runtime directly. When the cast fails the call goes through a null pointer and the process dies with SIGSEGV.

routing_manager_impl::init() dereferenced the result of
dynamic_pointer_cast<sd::runtime> directly. When the cast fails the
call goes through a null pointer and the process dies with SIGSEGV.
Comment on lines 163 to +171
auto its_plugin = plugin_manager::get()->get_plugin(plugin_type_e::SD_RUNTIME_PLUGIN, VSOMEIP_SD_LIBRARY);
if (its_plugin) {
VSOMEIP_INFO << "Service Discovery module loaded.";
discovery_ = std::dynamic_pointer_cast<sd::runtime>(its_plugin)->create_service_discovery(this, configuration_);
discovery_->init();
auto its_runtime = std::dynamic_pointer_cast<sd::runtime>(its_plugin);
if (!its_runtime) {
// Happens when the loaded module provides a different sd::runtime than this library expects
VSOMEIP_ERROR << "Service Discovery module does not provide a valid runtime!";
std::exit(EXIT_FAILURE);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check makes sense, but it does need that a weird/custom sd plugin is used. And there's a library split rework in >= 3.8 that already removed this code

@pgajdzis-volvo what's your use-case? I'd be interested in understanding it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've confirmed the crash site and the null cast result exactly, but have not yet confirmed why the cast fails in our environment, maybe two libs come from different builds.

We can drop this PR if split rework already removed this code in >=3.8 and no one before reached this issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgajdzis-volvo either that or .. one of the libs (-sd?) was built without rtti?

In either case sounds like you have a strange environment 😆

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

Successfully merging this pull request may close these issues.

2 participants