Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs detected by the address sanitizer #2212

Merged
merged 23 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
58c4692
Virtual destructor for CMeshReaderFVM
Feb 14, 2024
540d423
Fix memory leaks related to ActDisk
Feb 14, 2024
c4f94f2
Fix memory leak related to CSolver::Res_Conv_j
Feb 14, 2024
b77c0c6
Fix memory leaks related to CAdjEulerSolver::DonorAdjVar
Feb 14, 2024
44e75c5
Fix memory leaks related to CAdjEulerSolver::DonorGlobalIndex
Feb 14, 2024
e97da26
Fix memory leak related to CAvgGrad_AdjFlow::Mean_GradPhi
Feb 14, 2024
1118886
Fix 540d4239
Feb 14, 2024
ac74223
Fix memory leak related to CSolver::Vector_i, Vector_j
Feb 14, 2024
40d0fe8
Reset upon AD finalization for proper deallocation.
jblueh Feb 14, 2024
1cd38e1
Remove unused (and leaked) CDiscAdjFEAIteration::fem_iteration.
jblueh Feb 14, 2024
a37d83f
Fix semicolon.
jblueh Feb 14, 2024
7763f5c
Fix memory leak regarding CFEANonlinearElasticity::ke_DE_i.
jblueh Feb 14, 2024
4119f46
Replace Restart_Vars and Restart_Data by vectors.
jblueh Feb 14, 2024
ed6beac
Explicitly shrink vectors to free memory.
jblueh Feb 14, 2024
094f369
Fix.
jblueh Feb 14, 2024
19ab7ff
Reset vectors by move-assigning an empty vector.
jblueh Feb 15, 2024
73c59fb
Remove unnecessary semicolon
maxaehle Feb 15, 2024
fc23554
Separate marker lists for MARKER_ACTDISK_BEM_CG, ..._AXIS
maxaehle Feb 15, 2024
545843f
Store CIteration::TurbomachineryStagePerformance via shared_ptr
Feb 15, 2024
4c3253c
Merge remote-tracking branch 'github/fix_addresssanitizer_findings' i…
maxaehle Feb 15, 2024
85436ea
Fix formatting.
jblueh Feb 16, 2024
bb8553c
Merge branch 'develop' into fix_addresssanitizer_findings
jblueh Feb 16, 2024
150d1b3
Merge branch 'develop' into fix_addresssanitizer_findings
jblueh Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class CConfig {
*Marker_CHTInterface, /*!< \brief Conjugate heat transfer interface markers. */
*Marker_ActDiskInlet, /*!< \brief Actuator disk inlet markers. */
*Marker_ActDiskOutlet, /*!< \brief Actuator disk outlet markers. */
*Marker_ActDiskBemInlet, /*!< \brief Actuator disk BEM inlet markers. */
*Marker_ActDiskBemOutlet, /*!< \brief Actuator disk BEM outlet markers. */
*Marker_ActDiskBemInlet=nullptr, /*!< \brief Actuator disk BEM inlet markers. */
*Marker_ActDiskBemOutlet=nullptr, /*!< \brief Actuator disk BEM outlet markers. */
*Marker_Inlet, /*!< \brief Inlet flow markers. */
*Marker_Inlet_Species, /*!< \brief Inlet species markers. */
*Marker_Inlet_Turb, /*!< \brief Inlet turbulent markers. */
Expand Down
2 changes: 1 addition & 1 deletion Common/include/geometry/meshreader/CBoxMeshReaderFVM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ class CBoxMeshReaderFVM : public CMeshReaderFVM {
/*!
* \brief Destructor of the CBoxMeshReaderFVM class.
*/
~CBoxMeshReaderFVM(void);
~CBoxMeshReaderFVM(void) override;
};
2 changes: 1 addition & 1 deletion Common/include/geometry/meshreader/CCGNSMeshReaderFVM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ class CCGNSMeshReaderFVM : public CMeshReaderFVM {
/*!
* \brief Destructor of the CCGNSMeshReaderFVM class.
*/
~CCGNSMeshReaderFVM(void);
~CCGNSMeshReaderFVM(void) override;
};
2 changes: 2 additions & 0 deletions Common/include/geometry/meshreader/CMeshReaderFVM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class CMeshReaderFVM {
*/
CMeshReaderFVM(const CConfig* val_config, unsigned short val_iZone, unsigned short val_nZone);

virtual ~CMeshReaderFVM() = default;

/*!
* \brief Get the physical dimension of the problem (2 or 3).
* \returns Physical dimension of the problem.
Expand Down
19 changes: 18 additions & 1 deletion Common/include/option_structure.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,22 @@ class COptionActDisk : public COptionBase {
this->name = name;
}

~COptionActDisk() override{};
~COptionActDisk() override {
for (int i = 0; i < this->inlet_size; i++) {
delete[] this->press_jump[i];
delete[] this->temp_jump[i];
delete[] this->omega[i];
}
delete[] press_jump;
delete[] temp_jump;
delete[] omega;

delete[] marker_inlet;
delete[] marker_outlet;

SetDefault();
};
maxaehle marked this conversation as resolved.
Show resolved Hide resolved

string SetValue(const vector<string>& option_value) override {
COptionBase::SetValue(option_value);
const int mod_num = 8;
Expand All @@ -1717,7 +1732,9 @@ class COptionActDisk : public COptionBase {
unsigned short nVals = totalVals / mod_num;
this->inlet_size = nVals;
this->outlet_size = nVals;
delete[] this->marker_inlet;
this->marker_inlet = new string[this->inlet_size];
delete[] this->marker_outlet;
this->marker_outlet = new string[this->outlet_size];

this->press_jump = new su2double*[this->inlet_size];
Expand Down
10 changes: 5 additions & 5 deletions SU2_CFD/include/solvers/CAdjEulerSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class CAdjEulerSolver : public CSolver {
*Sens_Press, /*!< \brief Pressure sensitivity coefficient for each boundary. */
*Sens_Temp, /*!< \brief Temperature sensitivity coefficient for each boundary. */
*Sens_BPress, /*!< \brief Back pressure sensitivity coefficient for each boundary. */
**CSensitivity, /*!< \brief Shape sensitivity coefficient for each boundary and vertex. */
***DonorAdjVar; /*!< \brief Value of the donor variables at each boundary. */
**CSensitivity; /*!< \brief Shape sensitivity coefficient for each boundary and vertex. */
vector<vector<vector<su2double>>> DonorAdjVar; /*!< \brief Value of the donor variables at each boundary. */
su2double Total_Sens_Mach; /*!< \brief Total mach sensitivity coefficient for all the boundaries. */
su2double Total_Sens_AoA; /*!< \brief Total angle of attack sensitivity coefficient for all the boundaries. */
su2double Total_Sens_Geo; /*!< \brief Total shape sensitivity coefficient for all the boundaries. */
Expand All @@ -63,7 +63,7 @@ class CAdjEulerSolver : public CSolver {
su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */
su2double *FlowPrimVar_i, /*!< \brief Store the flow solution at point i. */
*FlowPrimVar_j; /*!< \brief Store the flow solution at point j. */
unsigned long **DonorGlobalIndex; /*!< \brief Value of the donor global index. */
vector<vector<unsigned long>> DonorGlobalIndex; /*!< \brief Value of the donor global index. */

su2double pnorm,
Area_Monitored; /*!< \brief Store the total area of the monitored outflow surface (used for normalization in continuous adjoint outflow conditions) */
Expand Down Expand Up @@ -219,8 +219,8 @@ class CAdjEulerSolver : public CSolver {
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the coefficient is evaluated.
* \return Value of the pressure coefficient.
*/
inline su2double *GetDonorAdjVar(unsigned short val_marker, unsigned long val_vertex) const {
return DonorAdjVar[val_marker][val_vertex];
inline const su2double* GetDonorAdjVar(unsigned short val_marker, unsigned long val_vertex) const {
return DonorAdjVar[val_marker][val_vertex].data();
}

/*!
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow() {
delete [] Mean_GradPsiE;
for (unsigned short iDim = 0; iDim < nDim; iDim++)
delete [] Mean_GradPhi[iDim];
delete [] Mean_GradPhi;
}

void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j,
Expand Down
20 changes: 5 additions & 15 deletions SU2_CFD/src/solvers/CAdjEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ CAdjEulerSolver::CAdjEulerSolver() : CSolver() {
CSensitivity = nullptr;
FlowPrimVar_i = nullptr;
FlowPrimVar_j = nullptr;
DonorAdjVar = nullptr;
DonorGlobalIndex = nullptr;

}

Expand Down Expand Up @@ -85,8 +83,6 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned
CSensitivity = nullptr;
FlowPrimVar_i = nullptr;
FlowPrimVar_j = nullptr;
DonorAdjVar = nullptr;
DonorGlobalIndex = nullptr;

/*--- Set the gamma value ---*/
Gamma = config->GetGamma();
Expand Down Expand Up @@ -188,25 +184,19 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned

/*--- Store the value of the characteristic primitive variables at the boundaries ---*/

DonorAdjVar = new su2double** [nMarker];
DonorAdjVar.resize(nMarker);
for (iMarker = 0; iMarker < nMarker; iMarker++) {
DonorAdjVar[iMarker] = new su2double* [geometry->nVertex[iMarker]];
DonorAdjVar[iMarker].resize(geometry->nVertex[iMarker]);
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
DonorAdjVar[iMarker][iVertex] = new su2double [nVar];
for (iVar = 0; iVar < nVar; iVar++) {
DonorAdjVar[iMarker][iVertex][iVar] = 0.0;
}
DonorAdjVar[iMarker][iVertex].resize(nVar, 0.0);
}
}

/*--- Store the value of the characteristic primitive variables index at the boundaries ---*/

DonorGlobalIndex = new unsigned long* [nMarker];
DonorGlobalIndex.resize(nMarker);
for (iMarker = 0; iMarker < nMarker; iMarker++) {
DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]];
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
DonorGlobalIndex[iMarker][iVertex] = 0;
}
DonorGlobalIndex[iMarker].resize(geometry->nVertex[iMarker],0);
}

Sens_Geo = new su2double[nMarker];
Expand Down
16 changes: 5 additions & 11 deletions SU2_CFD/src/solvers/CAdjNSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,19 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short

/*--- Store the value of the characteristic primitive variables at the boundaries ---*/

DonorAdjVar = new su2double** [nMarker];
DonorAdjVar.resize(nMarker);
for (iMarker = 0; iMarker < nMarker; iMarker++) {
DonorAdjVar[iMarker] = new su2double* [geometry->nVertex[iMarker]];
DonorAdjVar[iMarker].resize(geometry->nVertex[iMarker]);
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
DonorAdjVar[iMarker][iVertex] = new su2double [nVar];
for (iVar = 0; iVar < nVar; iVar++) {
DonorAdjVar[iMarker][iVertex][iVar] = 0.0;
}
DonorAdjVar[iMarker][iVertex].resize(nVar, 0.0);
}
}

/*--- Store the value of the characteristic primitive variables at the boundaries ---*/

DonorGlobalIndex = new unsigned long* [nMarker];
DonorGlobalIndex.resize(nMarker);
for (iMarker = 0; iMarker < nMarker; iMarker++) {
DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]];
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
DonorGlobalIndex[iMarker][iVertex] = 0;
}
DonorGlobalIndex[iMarker].resize(geometry->nVertex[iMarker],0);
}

Sens_Geo = new su2double[nMarker];
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/src/solvers/CSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ CSolver::~CSolver() {
delete [] Res_Visc;
delete [] Res_Sour;
delete [] Res_Conv_i;
delete [] Res_Conv_j;
delete [] Res_Visc_i;
delete [] Res_Visc_j;

Expand Down
Loading