robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
170 stars 67 forks source link

Clang Static analyzer issues #267

Open francesco-romano opened 7 years ago

francesco-romano commented 7 years ago

While running the static analyzer on the iDynTree code, I found some apparently not problematic issues, like the following:

MatrixDynSize.cpp:108:5: Null pointer argument in call to memory copy function

with the associated stack, e.g.

screen shot 2017-03-06 at 12 50 47

The problem is that (taken from documentation of std::memcpy)

If either dest or src is a null pointer, the behavior is undefined, even if count is zero.

cc @traversaro

francesco-romano commented 7 years ago

@traversaro we are missing the "Volunteers needed" label 🤣

francesco-romano commented 7 years ago

There are more than one of this kind of (subtle) issues. We should find time to fix them.

francesco-romano commented 7 years ago

These are the issues found in idyntree-core


ArticulatedBodyInertia.cpp:192:5: Assigned value is garbage or undefined (within a call to 'operator=')

ArticulatedBodyInertia.cpp:205:5: Assigned value is garbage or undefined (within a call to 'operator=')

ArticulatedBodyInertia.cpp:231:5: Assigned value is garbage or undefined (within a call to 'operator=')

ArticulatedBodyInertia.cpp:249:5: Assigned value is garbage or undefined (within a call to 'operator=')

ClassicalAcc.cpp:41:5: Assigned value is garbage or undefined (within a call to 'operator=')

GeomVector3.cpp:209:9: Assigned value is garbage or undefined (within a call to 'operator=')

InertiaNonLinearParametrization.cpp:178:5: Assigned value is garbage or undefined (within a call to 'operator=')

MatrixDynSize.cpp:108:5: Null pointer argument in call to memory copy function

MatrixDynSize.cpp:236:24: Potential leak of memory pointed to by 'localBuf'

MatrixDynSize.cpp:245:13: Null pointer argument in call to memory copy function

Rotation.cpp:169:9: Assigned value is garbage or undefined (within a call to 'operator=')

RotationRaw.cpp:68:9: Assigned value is garbage or undefined (within a call to 'operator=')

RotationRaw.cpp:78:9: Assigned value is garbage or undefined (within a call to 'operator=')

RotationRaw.cpp:91:9: Assigned value is garbage or undefined (within a call to 'operator=')

RotationRaw.cpp:116:9: Assigned value is garbage or undefined (within a call to 'operator=')

RotationRaw.cpp:130:9: Assigned value is garbage or undefined (within a call to 'operator=')

RotationRaw.cpp:146:9: Assigned value is garbage or undefined (within a call to 'operator=')

SpatialInertia.cpp:138:66: The right operand of '*' is a garbage value (within a call to 'cross')

SpatialInertia.cpp:247:5: The left operand of '-' is a garbage value (within a call to 'compute')

SpatialInertiaRaw.cpp:168:5: Assigned value is garbage or undefined (within a call to 'operator=')

Transform.cpp:413:9: Assigned value is garbage or undefined (within a call to 'operator=')

Transform.cpp:438:9: Assigned value is garbage or undefined (within a call to 'operator=')

Transform.cpp:452:9: Assigned value is garbage or undefined (within a call to 'operator=')

Transform.cpp:486:9: Assigned value is garbage or undefined (within a call to 'operator=')

Transform.cpp:504:9: Assigned value is garbage or undefined (within a call to 'operator=')

TransformDerivative.cpp:102:5: Assigned value is garbage or undefined (within a call to 'operator=')

TransformDerivative.cpp:123:5: Assigned value is garbage or undefined (within a call to 'operator=')

TransformDerivative.cpp:142:5: Assigned value is garbage or undefined (within a call to 'operator=')

TransformDerivative.cpp:166:5: Assigned value is garbage or undefined (within a call to 'operator=')

TransformDerivative.cpp:202:5: Assigned value is garbage or undefined (within a call to 'operator=')

TransformDerivative.cpp:220:5: Assigned value is garbage or undefined (within a call to 'operator=')
traversaro commented 7 years ago

This kind of warnings could be generated by the CI using scan-build ( http://clang-analyzer.llvm.org/ ) .