sandialabs / Albany

Sandia National Laboratories' Albany multiphysics code
Other
282 stars 89 forks source link

Albany warning-free array-bounds error on Blake #1014

Closed mcarlson801 closed 1 year ago

mcarlson801 commented 1 year ago

The blake warning-free build is failing with an array-bounds warning-as-error.

/home/projects/albany/nightlyCDashTrilinosBlake/build-gcc/TrilinosDebugInstallGccNoWarn/include/Sacado_StaticArrayTraits.hpp:87:20: error: 'void* memset(void*, int, size_t)' offset [136, 137438953416] is out of the bounds [0, 128] of object 'val' with type 'LandIce::EnthalpyBasalResid<PHAL::AlbanyTraits::HessianVec, PHAL::AlbanyTraits, Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::DynamicStorage<Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::StaticFixedStorage<double, 1> >, Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::StaticFixedStorage<double, 1> > > > >::ScalarT [4]' {aka 'Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::DynamicStorage<Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::StaticFixedStorage<double, 1> >, Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::StaticFixedStorage<double, 1> > > > [4]'} [-Werror=array-bounds]

The error output points to the Enthalpy_BasalResid kernel when specialized for EvalT = HessianVec and the array-bounds error seems to be related to the Sacado type.

In file included from [Albany/src/landIce/evaluators/LandIce_EnthalpyBasalResid.cpp:11](https://blob/master/Albany/src/landIce/evaluators/LandIce_EnthalpyBasalResid.cpp#L11): /.../repos-gcc/Albany/src/landIce/evaluators/LandIce_EnthalpyBasalResid_Def.hpp: In member function 'void LandIce::EnthalpyBasalResid<EvalT, Traits, Type>::operator()(const Enthalpy_Basal_Residual_Tag&, const int&) const [with EvalT = PHAL::AlbanyTraits::HessianVec; Traits = PHAL::AlbanyTraits; Type = Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::DynamicStorage<Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::StaticFixedStorage<double, 1> >, Sacado::Fad::Exp::GeneralFad<Sacado::Fad::Exp::StaticFixedStorage<double, 1> > > >]

I tried running the Enthalpy tests with a debug build of Trilinos with array bounds checking enabled and there were no array-bounds errors so I wonder if this specialization gets compiled but never actually used. Does anyone who knows more about HessianVec know why this might be showing up? I think the blake build uses default DFad types.

bartgol commented 1 year ago

I don't see the line number in the landice evaluator, but I'm guessing it's this:

ScalarT val[maxNumNodesPerSide];

We could try to do

ScalarT val[maxNumNodesPerSide] = {};

That should force all elements to be default-inited, rather than left uninitialized...