Repository navigation
routing: Guard the Service Discovery runtime cast - #1073
pgajdzis-volvo wants to merge 1 commit into
Conversation
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.
| 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); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@pgajdzis-volvo either that or .. one of the libs (-sd?) was built without rtti?
In either case sounds like you have a strange environment 😆
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.