In ExprEngine::bindReturnValue() we cast an SVal to DefinedOrUnknownSVal,
however this SVal can also be Undefined, which leads to an assertion failure.
Fixes: #56873
Differential D130974
[analyzer] Fix for the crash in #56873 isuckatcs on Aug 2 2022, 2:34 AM. Authored by
Details In ExprEngine::bindReturnValue() we cast an SVal to DefinedOrUnknownSVal, Fixes: #56873
Diff Detail
Event TimelineComment Actions Thanks, LGTM!
Comment Actions Some checker should have caught the uninitialized value earlier than the defaultEvalCall(). Other than that, I think it's a good practice to not rely on some checkers to catch things to prevent crashes; so this 'fix' seems reasonable to me.
Comment Actions
I definitely think it's worth catching it. I'm working on a checker which addresses this in D131299. It was originally intended to be a part of MallocChecker but has been moved to a separate one. Comment Actions If so, shouldn't be some dependencies across these revisions? You could also specify an additional RUN line to demonstrate that this can be caught by an experimental configuration. Comment Actions
I don't think they are that closely related. This patch is about fixing an assertion failure. This assertion failure happens because we don't handle a case not because the checker doesn't exist. |
I'm not a fan of mutating values like this.
Alternatively we could have used something like this at the point of use:
Size.getAs<DefinedOrUnknownSVal>().getValueOr(UnknownVal{})
I'm not sure if it's more readable :D