This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Do not attempt to get the pointee of void* .
ClosedPublic

Authored by alexander-shaposhnikov on Jan 22 2018, 2:38 PM.

Details

Summary

Do not attempt to get the pointee of void* while generating a bug report
(otherwise it will trigger an assert inside RegionStoreManager::getBinding
assert(!T->isVoidType() && "Attempting to dereference a void pointer!")).
(the call stack:

(anonymous namespace)::RegionStoreManager::getBinding
clang::ento::ProgramState::getSVal
clang::ento::StackHintGeneratorForSymbol::getMessage
clang::ento::PathDiagnosticEventPiece::getCallStackMessage 
....

)
Test plan: make check-all

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ added a comment.Jan 22 2018, 3:22 PM

Hmm, the original code seems quite quick-and-dirty. It, indeed, tries to blindly dereference something that's accidentally "some pointer".

Could you change the type check to consider AST types instead, i.e. check that (*I)->getType() is a double-pointer type? And then pass its single-pointee type into getSVal as the second optional argument, so that it knew what to expect. This would be the correct way to express what the author was trying to say.

Because your code ignores possible layers of sub-regions contained within Reg, and i'm afraid we may loose notes because of that.

(in any case there are many more ways in which a pointer can be passed into a function that this visitor doesn't pattern-match, but that's not super problematic)

switched to checking (*I)->getType()

NoQ accepted this revision.Jan 24 2018, 1:49 PM

Yeah, i guess that'd work as well :)

This revision is now accepted and ready to land.Jan 24 2018, 1:49 PM
This revision was automatically updated to reflect the committed changes.