Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
- name: "Run for ${{ matrix.os }}"
shell: bash
working-directory: ${{runner.workspace}}
run: ctest -S ${{ github.event.repository.name }}/gismo/cmake/ctest_script.cmake -D CTEST_BUILD_NAME="${{ github.event.repository.name }}_actions_$GITHUB_RUN_NUMBER" -D CTEST_CONFIGURATION_TYPE=RelWithDebInfo -D LABELS_FOR_SUBPROJECTS="gsUnstructuredSplines-tutorials" -D CTEST_SITE="${{ matrix.os }}_[actions]" -D CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE;-DCMAKE_CXX_STANDARD=11;-DGISMO_WITH_XDEBUG=ON;-DGISMO_BUILD_UNITTESTS=ON" -D GISMO_OPTIONAL='gsStructuralAnalysis\\;gsKLShell\\;gsSpectra\\;${{ github.event.repository.name }}' -Q
run: ctest -S ${{ github.event.repository.name }}/gismo/cmake/ctest_script.cmake -D CTEST_BUILD_NAME="${{ github.event.repository.name }}_actions_$GITHUB_RUN_NUMBER" -D CTEST_CONFIGURATION_TYPE=RelWithDebInfo -D LABELS_FOR_SUBPROJECTS="gsUnstructuredSplines-tutorials" -D CTEST_SITE="${{ matrix.os }}_[actions]" -D CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE;-DCMAKE_CXX_STANDARD=11;-DGISMO_WITH_XDEBUG=ON;-DGISMO_BUILD_UNITTESTS=ON" -D GISMO_OPTIONAL='gsStructuralAnalysis\\;gsKLShell\\;${{ github.event.repository.name }}' -Q
2 changes: 1 addition & 1 deletion src/gsAlmostC1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <gsHSplines/gsHTensorBasis.h>
#include <gsHSplines/gsTHBSpline.h>

#include <gsAssembler/gsExprHelper.h>
#include <gsExpressions/gsExprHelper.h>
#include <gsAssembler/gsExprEvaluator.h>
#include <gsAssembler/gsAssembler.h>

Expand Down
2 changes: 1 addition & 1 deletion src/gsDPatchBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ class gsDPatchBase
// }

protected:
const gsMultiPatch<T> & m_patches;
const gsMultiPatch<T> m_patches;
const gsMultiBasis<T> m_Bbases; // reference?

gsMultiBasis<T> m_bases;
Expand Down
2 changes: 1 addition & 1 deletion src/gsDPatchBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <gsHSplines/gsHTensorBasis.h>
#include <gsHSplines/gsTHBSpline.h>

#include <gsAssembler/gsExprHelper.h>
#include <gsExpressions/gsExprHelper.h>
#include <gsAssembler/gsExprEvaluator.h>
#include <gsAssembler/gsAssembler.h>

Expand Down
2 changes: 1 addition & 1 deletion src/gsMPBESBSplineBasis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ gsMPBESBSplineBasis<d,T>::gsMPBESBSplineBasis( gsMultiPatch<T> const & mp, index
//topol.computeAllVertices();
for (size_t i = 0; i < mp.nPatches(); i++)
{
GISMO_ASSERT(dynamic_cast<gsTensorBSplineBasis<2> * >(& mp.basis(i))!=NULL,"Bases is not of type gsTensorBSplineBasis<2>");
GISMO_ASSERT(dynamic_cast<const gsTensorBSplineBasis<2> * >(& mp.basis(i))!=NULL,"Bases is not of type gsTensorBSplineBasis<2>");
}
m_topol = mp;
m_bases = mp.basesCopy();
Expand Down
4 changes: 2 additions & 2 deletions src/gsMPBESHSplineBasis.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class gsMPBESHSplineBasis : public gsMPBESBasis<d,T>
gsMPBESHSplineBasis<d,T>& operator=( const gsMPBESHSplineBasis& other );

~gsMPBESHSplineBasis()
{
{

} //destructor

Expand All @@ -123,7 +123,7 @@ class gsMPBESHSplineBasis : public gsMPBESBasis<d,T>
gsHTensorBasis<d,T> & basis(size_t i)
{ return static_cast<gsHTensorBasis<d,T>&>(*m_bases[i]); }

const gsHTensorBasis<d,T> & basis(size_t i) const
const gsHTensorBasis<d,T> & basis(size_t i) const
{ return static_cast<const gsHTensorBasis<d,T>&>(*m_bases[i]); }

unsigned basisFunctionsOnSide(const patchSide& ps) const;
Expand Down
2 changes: 1 addition & 1 deletion src/gsMPBESHSplineBasis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis( gsMultiPatch<T> const & mp, index
//topol.computeAllVertices();
for (size_t i = 0; i < mp.nPatches(); i++)
{
GISMO_ASSERT(dynamic_cast<gsHTensorBasis<2> * >(& mp.basis(i))!=NULL,"Bases is not of type gsHTensorBasis<2>");
GISMO_ASSERT(dynamic_cast<const gsHTensorBasis<2> * >(& mp.basis(i))!=NULL,"Bases is not of type gsHTensorBasis<2>");
}
m_topol = mp;
m_bases = mp.basesCopy();
Expand Down
17 changes: 13 additions & 4 deletions src/gsMPBESUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gsMPBESBasis<d,T> * getCompBasisFromMultiPatch(const gsMultiPatch<T> & mp,index_
std::vector<gsTensorBSplineBasis<d,T>* >tensorBases;
for(size_t i = 0;i<mp.nPatches();++i)
{
tensorBases.push_back(dynamic_cast<gsTensorBSplineBasis<d,T> * >(& mp.basis(i)));
tensorBases.push_back(dynamic_cast<gsTensorBSplineBasis<d,T> * >(mp.basis(i).clone().release()));
tensorBSpline = tensorBSpline && tensorBases[i]!=NULL;
}
if(tensorBSpline)
Expand All @@ -32,12 +32,14 @@ gsMPBESBasis<d,T> * getCompBasisFromMultiPatch(const gsMultiPatch<T> & mp,index_
std::vector<gsHTensorBasis<d,T>* >hBases;
for(size_t i = 0;i<mp.nPatches();++i)
{
hBases.push_back(dynamic_cast<gsHTensorBasis<d,T> * >(& mp.basis(i)));
hBases.push_back(dynamic_cast<gsHTensorBasis<d,T> * >(mp.basis(i).clone().release()));
hTensor = hTensor && hBases[i]!=NULL;
}
if(hTensor)
compBasis = (new gsMPBESHSplineBasis<d,T>(hBases,mp,incrSmoothness,minEVDistance));
freeAll(hBases);

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling freeAll on hBases after passing them to the gsMPBESHSplineBasis constructor may free memory still in use by the new basis, leading to dangling pointers. Consider transferring ownership fully to gsMPBESHSplineBasis or removing this freeAll to avoid premature deletion.

Suggested change
freeAll(hBases);
// Removed freeAll(hBases) to avoid premature deletion and dangling pointers.

Copilot uses AI. Check for mistakes.
}
freeAll(tensorBases);

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unconditionally freeing tensorBases may invalidate data needed by the constructed gsMPBESBasis, causing potential use-after-free. Consider only cleaning up when ownership is not passed to the basis or deferring cleanup until after the basis is destroyed.

Copilot uses AI. Check for mistakes.
GISMO_ASSERT(tensorBSpline||hTensor,"No suitable basis for gsMappedBasis found.");
return compBasis;
}
Expand All @@ -51,7 +53,7 @@ gsMPBESBasis<d,T> * getCompBasisFromMultiPatch_withCoefs(const gsMultiPatch<T> &
std::vector<gsTensorBSplineBasis<d,T>* >tensorBases;
for(size_t i = 0;i<mp.nPatches();++i)
{
tensorBases.push_back(dynamic_cast<gsTensorBSplineBasis<d,T> * >(& mp.basis(i)));
tensorBases.push_back(dynamic_cast<gsTensorBSplineBasis<d,T> * >(mp.basis(i).clone().release()));
tensorBSpline = tensorBSpline && tensorBases[i]!=NULL;
}
if(tensorBSpline)
Expand All @@ -61,12 +63,19 @@ gsMPBESBasis<d,T> * getCompBasisFromMultiPatch_withCoefs(const gsMultiPatch<T> &
std::vector<gsHTensorBasis<d,T>* >hBases;
for(size_t i = 0;i<mp.nPatches();++i)
{
hBases.push_back(dynamic_cast<gsHTensorBasis<d,T> * >(& mp.basis(i)));
hBases.push_back(dynamic_cast<gsHTensorBasis<d,T> * >(mp.basis(i).clone().release()));
hTensor = hTensor && hBases[i]!=NULL;
}
if(hTensor)
compBasis = (new gsMPBESHSplineBasis<d,T>(hBases,mp,coefs,incrSmoothness,minEVDistance));
// Remove HBasis pointers since they are cloned inside the constructor of the gsMPBESHSplineBasis
if (hBases.size()>0)
freeAll(hBases);
}
// Remove BSpline pointers since they are cloned inside the constructor of the gsMPBESBSplineBasis
if (tensorBases.size()>0)
freeAll(tensorBases);

GISMO_ASSERT(tensorBSpline||hTensor,"No suitable basis for gsMappedBasis found.");
return compBasis;
}
Expand Down