llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[analyzer] getenv() state split missing a note.

Open haoNoQ opened this issue 4 years ago • 7 comments

Now that we're bifurcating on getenv() by default, we should explain to the user why we think that the pointer may be null. Eg. this isn't an understandable report:

Screen Shot 2022-01-18 at 2 51 43 PM

Ideally this should be a two-step report with the first step saying something like "Assuming the variable is not present in the environment".

@martong @steakhal how close are we to attaching note tag material to summaries?

P.S. I love the new bugzilla, was just waiting for a chance to use it^^

haoNoQ avatar Jan 18 '22 23:01 haoNoQ

Well, AFAIK there is currently no way in the StdLibraryChecker to add a NoteTag for a Case(). It shouldn't be hard to extend it with a "message". Or even better, with the NoteTag lambda itself. That way we could implement custom interestingness conditions for the message to appear. Of course, we could still provide a handy factory for creating the simple lambda wrapping the single string message for the generic case. WDYT?

Even though the DSL is already on the complex side, these NoteTags would be beneficial in all cases. More often than not we are interested in why something is assumed by the analyzer. So, an addTransition() without a NoteTag is like a code smell for me.

@martong @steakhal how close are we to attaching note tag material to summaries?

That being said, we haven't thought about this, but we definitely should have.

steakhal avatar Jan 19 '22 07:01 steakhal

Folks, are you actively working on this issue these days? I'm thinking of disabling the getenv split by default (eg., by disabling the controlled environment flag by default) if there's no quick fix for this issue.

haoNoQ avatar Mar 16 '22 05:03 haoNoQ

I'm not working on it. Would you please reflect on the proposed implementation in my previous post? If it looks good, I could pose this internally and maybe schedule it at some point. Otherwise, disable it if you feel like it.

steakhal avatar Mar 16 '22 09:03 steakhal

Yes, I think a simple string message is probably sufficient. Especially given that a summary should almost never have more than two branches anyway (very hard to justify a more-than-2-way state split).

haoNoQ avatar Mar 16 '22 22:03 haoNoQ

So, an addTransition() without a NoteTag is like a code smell for me.

I agree. It's often conditional or prunable but most of the time it has to be there.

haoNoQ avatar Mar 16 '22 22:03 haoNoQ

Solved by the referenced commit.

martong avatar May 27 '22 08:05 martong

Indeed, fixed by f68c0a2f58e484f008883ab290e36a36e851c1bf.

steakhal avatar May 27 '22 08:05 steakhal