This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix StdLibraryFunctionsChecker crash on macOS
ClosedPublic

Authored by vsavchenko on Jun 16 2020, 2:16 AM.

Details

Summary

EOF macro token coming from a PCH file on macOS while marked as literal,
doesn't contain any literal data. This causes crash on every project
using PCHs.

This commit doesn't resolve the problem with PCH (maybe it was
designed like this for a purpose) or with tryExpandAsInteger, but
rather simply shoots off a crash itself.

Diff Detail

Event Timeline

vsavchenko created this revision.Jun 16 2020, 2:16 AM
NoQ accepted this revision.Jun 16 2020, 2:44 AM

Thanks!

@martong, thoughts on this? :)

Also i guess in this test we're unable to obtain the value for EOF, what would be a good fixme-test to demonstrate that?

clang/test/Analysis/pch_crash.cpp
2

Just curious - did you double-check that only macos triples are affected? Maybe we should add a pair of run-lines without the triple, so that to automatically get coverage from buildbots on all platforms on which we have buildbots. Because the test should obviously pass on all platforms.

4

Can we enable core as well? Because we keep telling everybody that running without core is unsupported, so we tend to enable it on tests in order to demonstrate that.

22

Let's add sone comment like // no-crash so that to indicate what is it that we're testing for.

This revision is now accepted and ready to land.Jun 16 2020, 2:44 AM
NoQ added inline comments.Jun 16 2020, 2:45 AM
clang/test/Analysis/pch_crash.cpp
22

*some

Fix review comments

vsavchenko marked 5 inline comments as done.Jun 16 2020, 2:54 AM
vsavchenko added inline comments.
clang/test/Analysis/pch_crash.cpp
2

No, I didn't check that :(. I just know that this problem is not reproduced in docker (aka Ubuntu).

In D81916#2095106, @NoQ wrote:

Thanks!

@martong, thoughts on this? :)

Also i guess in this test we're unable to obtain the value for EOF, what would be a good fixme-test to demonstrate that?

I accept this as a very quick fix, but this seems to be an error rather in ASTReader and ASTWriter. And this could affect other modules related logic in macOS, not just the CSA. I wouldn't be surprised if LLDB develeopers were the next to struggle with the same ASTReader/Writer issue.

clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
131–133

Could you please add a FIXME above the line with the real reasons: "EOF macro token coming from a PCH file on macOS while marked as literal,
doesn't contain any literal data."

vsavchenko marked 2 inline comments as done.Jun 16 2020, 6:05 AM
vsavchenko added inline comments.
clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
131–133

Sure

martong accepted this revision.Jun 16 2020, 6:07 AM

Add FIXME comment

vsavchenko marked an inline comment as done.Jun 16 2020, 6:08 AM
This revision was automatically updated to reflect the committed changes.