Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb infer #4257

Merged
merged 16 commits into from
Oct 21, 2024
Merged

Fb infer #4257

merged 16 commits into from
Oct 21, 2024

Conversation

stt08
Copy link
Collaborator

@stt08 stt08 commented Jun 6, 2024

Adding facebook infer analyzer support
FIXES #4189

@stt08 stt08 requested review from dkrupp, bruntib and vodorok as code owners June 6, 2024 07:46
@vodorok
Copy link
Contributor

vodorok commented Jun 24, 2024

I've not tried it, but this integration should support the new 1.2.0 release of infer.
https://github.com/facebook/infer/releases/tag/v1.2.0

@stt08 stt08 force-pushed the fb-infer branch 9 times, most recently from c1c7a76 to a797330 Compare June 25, 2024 11:58
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check why the analysis does not work on postgresql
Please fix the description field of the infer checkers
There are other minor copy paste errors which you need to check

docs/analyzer/checker_and_analyzer_configuration.md Outdated Show resolved Hide resolved
docs/analyzer/checker_and_analyzer_configuration.md Outdated Show resolved Hide resolved
docs/examples/compile_commands.json Outdated Show resolved Hide resolved
analyzer/codechecker_analyzer/analyzers/infer/analyzer.py Outdated Show resolved Hide resolved
docs/analyzer/checker_and_analyzer_configuration.md Outdated Show resolved Hide resolved
@stt08 stt08 force-pushed the fb-infer branch 4 times, most recently from 9f41048 to 1fc70e9 Compare June 25, 2024 16:04
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the postgresql and the xerces analysis and add the fb infer license file.

@stt08 stt08 force-pushed the fb-infer branch 6 times, most recently from 122aa6a to c2d5a96 Compare August 13, 2024 15:41
@stt08 stt08 force-pushed the fb-infer branch 6 times, most recently from 5541091 to c66d534 Compare August 14, 2024 09:50
@dkrupp dkrupp self-requested a review August 26, 2024 15:08
@dkrupp
Copy link
Member

dkrupp commented Aug 27, 2024

I retried this PR with infer 1.1.0.

I could not list the checkers

CodeChecker checkers --analyzers infer
[ERROR 2024-08-26 17:08] - None
[ERROR 2024-08-26 17:08] - None
[INFO 2024-08-26 17:08] - No checkers with the given label found.

and I could not execute the analysis either, I guess because it could not list checker.

workspace/test-projects/xerces-c]$ CodeChecker analyze ./compile_commands.json --analyzers=infer -e infer -o ./reports-infer
[ERROR 2024-08-26 17:09] - None
[INFO 2024-08-26 17:09] - No checkers enabled for infer
[ERROR 2024-08-26 17:09] - No checker(s) with these names was found:
infer

I think the problem is that the timezone setting is incorrect for infer.

infer
Uncaught Internal Error: ("unknown zone" (zone :Europe/Budapest))
Error backtrace:
Raised at Base__Error.raise in file "src/error.ml" (inlined), line 8, characters 14-30
Called from Base__Error.raise_s in file "src/error.ml", line 9, characters 19-40
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from IBase__ResultsDir.RunState.run_time_string in file "src/base/ResultsDir.ml", line 14, characters 24-53

Run the command again with `--keep-going` to try and ignore this error.
(CodeChecker venv-dev) ednikru@seliiuvd02700[14:47][build/CodeChecker/bin]$ echo $?
2

Could you please print the stderror from the analyzer tool in as CodeChecker error log when invocation of the tools fails?
This way the user could debug a failing analyzer binary.

Or course when I set export TIMEZONE=UTC in my shell, infer was working correctly through CodeChecker. So this is about error handling.

Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please see my previous comment to print analysis errors to error log.

  2. Some valid reports seem to be lost

Analyzing postgresql latch.c

CodeChecker analyze ./compile_commands.json --analyzers infer -e infer -c --file "*/latch.c" -o ./reports_infer --verbose debug

INFO][2024-08-27 13:23:04] {analyzer} [2036841] <139720747276096> - analysis_manager.py:618 check() - [1/1] infer analyzed latch.c successfully.
[DEBUG_ANALYZER][2024-08-27 13:23:04] {analyzer} [2036841] <139720747276096> - analysis_manager.py:685 check() - 

latch.c:790: error: Dead Store
  The value written to &data (type char*) is never used.
  788. #if defined(WAIT_USE_EPOLL)
  789. 	set->epoll_ret_events = (struct epoll_event *) data;
  790. 	data += MAXALIGN(sizeof(struct epoll_event) * nevents);
        ^
  791. #elif defined(WAIT_USE_KQUEUE)
  792. 	set->kqueue_ret_events = (struct kevent *) data;

latch.c:1502: error: Dead Store
  The value written to &occurred_events (type WaitEvent*) is never used.
  1500. 				set->events[set->latch_pos].user_data;
  1501. 			occurred_events->events = WL_LATCH_SET;
  1502. 			occurred_events++;
           ^
  1503. 			returned_events++;
  1504. 


Found 2 issues
  Issue Type(ISSUED_TYPE_ID): #
      Dead Store(DEAD_STORE): 2

[DEBUG_ANALYZER][2024-08-27 13:23:04] {analyzer} [2036841] <139720747276096> - analysis_manager.py:686 check() - 
Capturing in make/cc mode...
Found 1 source file to analyze in /workspace/test-projects/postgres/reports_infer/infer/cd8fc2fbba52d017ee60954632245ada
latch.c starting
latch.c DONE

but the report directory seems to be empty, however it should contain the dead store report from latch.c

CodeChecker parse ./reports_infer/
Found no defects in latch.c

----======== Summary ========----
---------------------------------------------
Number of processed analyzer result files | 1
Number of analyzer reports                | 0
---------------------------------------------
----=================----

Also when I call
CodeChecker analyze ./compile_commands.json --analyzers infer -e infer -c --file "*/latch.c" -o ./reports_infer

what are these No source file found: latch.c warnings?

[INFO 2024-08-27 13:26] - Previous analysis results in '/workspace/test-projects/postgres/reports_infer' have been removed, overwriting with current result
[INFO 2024-08-27 13:27] - Enabled checker list can be found in /workspace/test-projects/postgres/reports_infer/metadata.json
[INFO 2024-08-27 13:27] - Starting static analysis ...
[WARNING 2024-08-27 13:27] - No source file found: latch.c
[WARNING 2024-08-27 13:27] - No source file found: latch.c
[INFO 2024-08-27 13:27] - [1/1] infer analyzed latch.c successfully.
[INFO 2024-08-27 13:27] - ----==== Summary ====----
[INFO 2024-08-27 13:27] - Successfully analyzed
[INFO 2024-08-27 13:27] -   infer: 1
[INFO 2024-08-27 13:27] - Total analyzed compilation commands: 1
[INFO 2024-08-27 13:27] - Skipped compilation commands: 1272
[INFO 2024-08-27 13:27] - ----=================----
[INFO 2024-08-27 13:27] - Analysis finished.
[INFO 2024-08-27 13:27] - To view results in the terminal use the "CodeChecker parse" command.
[INFO 2024-08-27 13:27] - To store results use the "CodeChecker store" command.
[INFO 2024-08-27 13:27] - See --help and the user guide for further options about parsing and storing the reports.
[INFO 2024-08-27 13:27] - ----=================----
[INFO 2024-08-27 13:27] - Analysis length: 2.0951790809631348 sec.

@stt08 stt08 force-pushed the fb-infer branch 2 times, most recently from 5f5105b to 42449f0 Compare August 27, 2024 17:04
@dkrupp
Copy link
Member

dkrupp commented Sep 13, 2024

Infer 1.1.0 drops the following error if the timezone is not set to UTC:

infer
Uncaught Internal Error: ("unknown zone" (zone :Europe/Budapest))
Error backtrace:
Raised at Base__Error.raise in file "src/error.ml" (inlined), line 8, characters 14-30
Called from Base__Error.raise_s in file "src/error.ml", line 9, characters 19-40
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from IBase__ResultsDir.RunState.run_time_string in file "src/base/ResultsDir.ml", line 14, characters 24-53

This also means that the
CodeChecker checkers --analyzers infer
lists nothing and the infer analyzer is unusable from under codechecker.

Please add the TZ=UTC environment variable where you invoke infer as a workaround.

TZ=UTC infer
Nothing to compile. Have you run `infer capture`? Try cleaning the build first.
There was nothing to analyze.

  No issues found  

like this, it works.

@stt08 stt08 force-pushed the fb-infer branch 3 times, most recently from b6e9a2c to ec2d0c9 Compare September 18, 2024 11:31
@dkrupp dkrupp merged commit a9076a6 into Ericsson:master Oct 21, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facebook Infer analyzer support
3 participants