Page MenuHomePhabricator

[analyzer] PR41239: Fix a crash on invalid source location in NoStoreFuncVisitor.

Authored by NoQ on Mar 27 2019, 1:40 PM.



It turns out that SourceManager::isInSystemHeader() crashes when an invalid source location is passed into it. Invalid source locations are relatively common: not only they come from body farms, but also, say, any function in C that didn't come with a forward declaration would have an implicit forward declaration with invalid source locations.

Not sure if this deserves to be fixed in SourceManager, but there's anyway a more comfy API for us to use in the Static Analyzer: CallEvent::isInSystemHeader(), so i just used that.

Diff Detail


Event Timeline

NoQ created this revision.Mar 27 2019, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2019, 1:40 PM
Charusso accepted this revision.Mar 27 2019, 1:52 PM

Nice solution.

This revision is now accepted and ready to land.Mar 27 2019, 1:52 PM
Szelethus accepted this revision.Mar 28 2019, 2:45 AM

An assert would be real nice in SourceManager, we should definitely add that, since some callbacks don't even receive a CallEvent object. My checker runs on checkPostCall, and also checks where fields lie in a system header.

I've posted another test case to It may already be covered by the fix. Could you check?

NoQ added a comment.Mar 29 2019, 3:53 PM

This other example seems to work and looks relatively similar, just with a different checker causing the visitor to be attached.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2019, 3:56 PM