Avoid segmentation fault if the Tracking item_type is not defined for the given implementation

This commit is contained in:
Carles Fernandez 2021-01-26 14:01:28 +01:00
parent 7f23b6d88b
commit 862bdeea5c
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
20 changed files with 32 additions and 19 deletions

View File

@ -23,7 +23,8 @@
#include "telemetry_decoder_interface.h"
#include "tracking_interface.h"
#include <glog/logging.h>
#include <utility> // for std::move
#include <stdexcept> // for std::invalid_argument
#include <utility> // for std::move
Channel::Channel(const ConfigurationInterface* configuration,
@ -113,6 +114,13 @@ void Channel::connect(gr::top_block_sptr top_block)
acq_->connect(top_block);
}
trk_->connect(top_block);
if (trk_->item_size() == 0)
{
std::string msg = trk_->role() + ".item_type is not defined for implementation " + trk_->implementation() + '\n';
throw std::invalid_argument(msg);
}
nav_->connect(top_block);
// Synchronous ports

View File

@ -72,7 +72,7 @@ BeidouB1iDllPllTracking::BeidouB1iDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -64,7 +64,7 @@ BeidouB3iDllPllTracking::BeidouB3iDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -65,7 +65,7 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}

View File

@ -74,7 +74,7 @@ GalileoE1TcpConnectorTracking::GalileoE1TcpConnectorTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -65,7 +65,7 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -66,7 +66,7 @@ GalileoE5bDllPllTracking::GalileoE5bDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -61,7 +61,7 @@ GalileoE6DllPllTracking::GalileoE6DllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -95,7 +95,7 @@ GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type_ << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -70,7 +70,7 @@ GlonassL1CaDllPllTracking::GlonassL1CaDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -93,7 +93,7 @@ GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type_ << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -68,7 +68,7 @@ GlonassL2CaDllPllTracking::GlonassL2CaDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -73,7 +73,7 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -72,7 +72,7 @@ GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -81,7 +81,7 @@ GpsL1CaKfTracking::GpsL1CaKfTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -60,7 +60,7 @@ GpsL1CaTcpConnectorTracking::GpsL1CaTcpConnectorTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << item_type << " unknown tracking item type.";
}

View File

@ -62,7 +62,7 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -65,7 +65,7 @@ GpsL5DllPllTracking::GpsL5DllPllTracking(
}
else
{
item_size_ = sizeof(gr_complex);
item_size_ = 0;
LOG(WARNING) << trk_params.item_type << " unknown tracking item type.";
}
channel_ = 0;

View File

@ -393,6 +393,11 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel(
{
return nullptr;
}
if (trk_->item_size() == 0)
{
LOG(ERROR) << trk_->role() << ".item_type=" << acq_item_type << " is not defined for implementation " << trk_->implementation();
return nullptr;
}
std::unique_ptr<GNSSBlockInterface> channel_ = std::make_unique<Channel>(configuration, channel,
std::move(acq_),

View File

@ -804,7 +804,7 @@ int GNSSFlowgraph::connect_channels()
else
{
LOG(ERROR) << "Can't connect channel " << i << " internally";
help_hint_ += " * Check implementation names for Channel" + std::to_string(i) + " inner blocks.\n";
help_hint_ += " * Check your configuration for Channel" + std::to_string(i) + " inner blocks.\n";
help_hint_ += " Acquisition blocks documentation at https://gnss-sdr.org/docs/sp-blocks/acquisition/\n";
help_hint_ += " Tracking blocks documentation at https://gnss-sdr.org/docs/sp-blocks/tracking/\n";
help_hint_ += " Telemetry Decoder blocks documentation at https://gnss-sdr.org/docs/sp-blocks/telemetry-decoder/\n";