Project Name | CID | Checker | Category | Developer Description |
---|---|---|---|---|
!CHAOS Control System | 125825 | RESOURCE_LEAK | Resource leaks | very useful to find this very horrible bug |
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
for(std::vector<std::string>::iterator it = command_alias.begin(); it != command_alias.end(); it++) { SCACU_LAPP_ << "Add input attribute for slow command:" << *it; domain_attribute_setting.addAttribute(*it, 255, DataType::TYPE_STRING); } } void SCAbstractControlUnit::submitSlowCommand(const std::string command_alias, CDataWrapper *slow_command_pack, uint64_t& command_id) { CHAOS_ASSERT(slow_command_executor) slow_command_executor->submitCommand(command_alias, slow_command_pack, command_id); } /* Receive the event for set the dataset input element */ CDataWrapper* SCAbstractControlUnit::setDatasetAttribute(CDataWrapper *datasetAttributeValues, bool& detachParam) throw (CException) { uint64_t command_id =0; CDataWrapper *result = NULL; |
< 1. Condition "datasetAttributeValues->hasKey(std::string const(chaos::common::batch_command::BatchCommandAndParameterDescriptionkey::BC_ALIAS, std::allocator<char>()))", taking true branch
254 |
if(datasetAttributeValues->hasKey(chaos_batch::BatchCommandAndParameterDescriptionkey::BC_ALIAS)) { |
< 2. Condition "!this->slow_command_executor", taking true branch
255 256 257 258 259 260 261 262 263 264 265 266 |
CHAOS_ASSERT(slow_command_executor) std::string command_alias = datasetAttributeValues->getStringValue(chaos_batch::BatchCommandAndParameterDescriptionkey::BC_ALIAS); // in slow control cu the CDataWrapper instance received from rpc is internally managed //so we need to detach it // submit the detacched command to slow controll subsystem slow_command_executor->submitCommand(command_alias, datasetAttributeValues, command_id); detachParam = true; //in this event the value is the alias of the command //publish command value AttributeValue *attr_value = attribute_value_shared_cache->getAttributeValue(DOMAIN_INPUT, command_alias); |
< 3. Condition "attr_value", taking true branch
267 268 269 270 271 272 273 274 275 276 277 278 |
if(attr_value) { std::string cmd_param = datasetAttributeValues->getJSONString(); //add new size attr_value->setNewSize((uint32_t)cmd_param.size()); //set the value without notify because command value are managed internally only attr_value->setValue(cmd_param.c_str(), (uint32_t)cmd_param.size(), true); //push input dataset change pushInputDataset(); } //construct the result |
<< 4. Storage is returned from allocation function "operator new".
<< 5. Assigning: "result" = storage returned from "new chaos::common::data::CDataWrapper".
279 |
result = new CDataWrapper(); |
<< 6. Resource "result" is not freed or pointed-to in "addInt64Value".
280 281 |
result->addInt64Value(chaos_batch::BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64, command_id); } |
<<< CID 125825: Resource leaks RESOURCE_LEAK <<< 7. Variable "result" going out of scope leaks the storage it points to.
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
return AbstractControlUnit::setDatasetAttribute(datasetAttributeValues, detachParam); } /* Event for update some CU configuration */ CDataWrapper* SCAbstractControlUnit::updateConfiguration(CDataWrapper *update_pack, bool& detach_param) throw (CException) { CDataWrapper *result = AbstractControlUnit::updateConfiguration(update_pack, detach_param); std::auto_ptr<CDataWrapper> cu_properties; CDataWrapper *cu_property_container = NULL; if(update_pack->hasKey(ControlUnitNodeDefinitionKey::THREAD_SCHEDULE_DELAY)){ cu_property_container = update_pack; } else if(update_pack->hasKey("property_abstract_control_unit") && update_pack->isCDataWrapperValue("property_abstract_control_unit")){ cu_properties.reset(update_pack->getCSDataValue("property_abstract_control_unit")); if(cu_properties->hasKey(ControlUnitNodeDefinitionKey::THREAD_SCHEDULE_DELAY)) { cu_property_container = cu_properties.get(); } } if(cu_property_container) { //we need to configure the delay from a run() call and the next uint64_t new_schedule_daly = cu_property_container->getUInt64Value(ControlUnitNodeDefinitionKey::THREAD_SCHEDULE_DELAY); chaos_batch::features::Features features; std::memset(&features, 0, sizeof(chaos_batch::features::Features)); //features.featuresFlag &= chaos_batch::features::FeaturesFlagTypes::FF_LOCK_USER_MOD; features.featureSchedulerStepsDelay = new_schedule_daly; |
4. alloc_fn | SCAbstractControlUnit.cpp:279 | |
5. var_assign | SCAbstractControlUnit.cpp:279 | |
6. noescape | SCAbstractControlUnit.cpp:280 | |
7. leaked_storage | SCAbstractControlUnit.cpp:282 |