Skip to content

Commit

Permalink
fix crash due to wrong treatment of pointers (see #104 (comment))
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannimarchiori committed Aug 29, 2024
1 parent 24fc6e0 commit 2a9e592
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions RecFCCeeCalorimeter/src/components/AugmentClustersFCCee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ StatusCode AugmentClustersFCCee::initialize()
showerShapeDecorations.push_back(Form("energy_fraction_%s_layer_%d", detector, layer));
showerShapeDecorations.push_back(Form("theta_%s_layer_%d", detector, layer));
showerShapeDecorations.push_back(Form("phi_%s_layer_%d", detector, layer));
showerShapeDecorations.push_back(Form("maxcell_E_%s_layer_%d", detector, layer));
// pi0/photon shape var only calculated in EMB
if (m_do_photon_shapeVar && m_systemIDs[k] == systemID_EMB) {
showerShapeDecorations.push_back(Form("maxcell_E_%s_layer_%d", detector, layer));
showerShapeDecorations.push_back(Form("width_theta_%s_layer_%d", detector, layer));
showerShapeDecorations.push_back(Form("width_module_%s_layer_%d", detector, layer));
showerShapeDecorations.push_back(Form("Ratio_E_max_2ndmax_%s_layer_%d", detector, layer));
Expand Down Expand Up @@ -651,7 +651,7 @@ StatusCode AugmentClustersFCCee::execute([[maybe_unused]] const EventContext &ev
return StatusCode::FAILURE;
}
width_theta[layer+startPositionToFill] = (sumEnLayer[layer+startPositionToFill] > 0.) ? std::sqrt(std::fabs(w_theta2)) : 0. ;
}
}
double w_module2 = module2_E_layer[layer+startPositionToFill] / sumEnLayer[layer+startPositionToFill] - std::pow(module_E_layer[layer+startPositionToFill] / sumEnLayer[layer+startPositionToFill], 2);
// Very small but negative values caused by computational precision are allowed,
// otherwise crash.
Expand Down
17 changes: 16 additions & 1 deletion RecFCCeeCalorimeter/src/components/CalibrateCaloClusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,24 @@ StatusCode CalibrateCaloClusters::finalize()
{
if (m_ortSession)
delete m_ortSession;

if (m_ortEnv)
delete m_ortEnv;

for (std::size_t i = 0; i < m_input_names.size(); i++) {
if (m_input_names.at(i)) {
delete m_input_names.at(i);
}
}
m_input_names.resize(0);

for (std::size_t i = 0; i < m_output_names.size(); i++) {
if (m_output_names.at(i)) {
delete m_output_names.at(i);
}
}
m_output_names.resize(0);

return Gaudi::Algorithm::finalize();
}

Expand Down Expand Up @@ -271,7 +286,7 @@ StatusCode CalibrateCaloClusters::readCalibrationFile(const std::string &calibra
#if ORT_API_VERSION < 13
m_output_names.emplace_back(AllocatedStringPtr(m_ortSession->GetOutputName(i, allocator), allocDeleter).release());
#else
m_output_names.emplace_back(m_ortSession->GetOutputNameAllocated(i, allocator).get());
m_output_names.emplace_back(m_ortSession->GetOutputNameAllocated(i, allocator).release());
#endif
m_output_shapes = m_ortSession->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape();
debug() << "\t" << m_output_names.at(i) << " : ";
Expand Down
17 changes: 16 additions & 1 deletion RecFCCeeCalorimeter/src/components/PhotonIDTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,24 @@ StatusCode PhotonIDTool::finalize()
{
if (m_ortSession)
delete m_ortSession;

if (m_ortEnv)
delete m_ortEnv;

for (std::size_t i = 0; i < m_input_names.size(); i++) {
if (m_input_names.at(i)) {
delete m_input_names.at(i);
}
}
m_input_names.resize(0);

for (std::size_t i = 0; i < m_output_names.size(); i++) {
if (m_output_names.at(i)) {
delete m_output_names.at(i);
}
}
m_output_names.resize(0);

return Gaudi::Algorithm::finalize();
}

Expand Down Expand Up @@ -341,7 +356,7 @@ StatusCode PhotonIDTool::readMVAFiles(const std::string& mvaInputsFileName,
#if ORT_API_VERSION < 13
m_output_names.emplace_back(AllocatedStringPtr(m_ortSession->GetOutputName(i, allocator), allocDeleter).release());
#else
m_output_names.emplace_back(m_ortSession->GetOutputNameAllocated(i, allocator).get());
m_output_names.emplace_back(m_ortSession->GetOutputNameAllocated(i, allocator).release());
#endif

m_output_shapes = m_ortSession->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape();
Expand Down

0 comments on commit 2a9e592

Please sign in to comment.