[buck] delete results dir inside buck-out in infer children processes

Summary:
The infer results directories in buck-out/ are "cleaned up" to avoid polluting
the Buck cache with too much data or non-deterministic data. In particular, the
runstate is deleted, which confused subsequent infer processes trying to read
the pre-existing results directory.

Add a special case in infer to delete pre-existing results directories in
buck-out instead of trying to load their state.

Reviewed By: mbouaziz

Differential Revision: D6845128

fbshipit-source-id: 5c716aa
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 025f3109bd
commit 586582c311

3
.gitignore vendored

@ -26,6 +26,7 @@ duplicates.txt
*.ast.sh *.ast.sh
*.ast.bdump *.ast.bdump
*.ast.biniou *.ast.biniou
/infer/tests/build_systems/buck_flavors_diff/src/hello.c
/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/libs/ /infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/libs/
/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/obj/ /infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/obj/
/infer/tests/build_systems/codetoanalyze/utf8_*n_pwd /infer/tests/build_systems/codetoanalyze/utf8_*n_pwd
@ -38,8 +39,6 @@ duplicates.txt
/infer/tests/build_systems/codetoanalyze/xcodebuild/simple_app/build/ /infer/tests/build_systems/codetoanalyze/xcodebuild/simple_app/build/
/infer/tests/build_systems/differential_*/**/*.class /infer/tests/build_systems/differential_*/**/*.class
/infer/tests/build_systems/differential_*/**/Diff*.java /infer/tests/build_systems/differential_*/**/Diff*.java
/infer/tests/build_systems/differential_*/infer-current
/infer/tests/build_systems/differential_*/infer-previous
/infer/tests/build_systems/diff/src /infer/tests/build_systems/diff/src
/infer/tests/build_systems/diff_*/src /infer/tests/build_systems/diff_*/src
/infer/tests/build_systems/buck_flavors_deterministic/capture_hash-*.sha /infer/tests/build_systems/buck_flavors_deterministic/capture_hash-*.sha

@ -35,11 +35,14 @@ let setup () =
ResultsDir.remove_results_dir () ; ResultsDir.create_results_dir () ResultsDir.remove_results_dir () ; ResultsDir.create_results_dir ()
| Capture | Compile | Run -> | Capture | Compile | Run ->
let driver_mode = Lazy.force Driver.mode_from_command_line in let driver_mode = Lazy.force Driver.mode_from_command_line in
if not if Config.(
( Driver.(equal_mode driver_mode Analyze) (* In Buck mode, delete infer-out directories inside buck-out to start fresh and to
|| avoid getting errors because some of their contents is missing (removed by
Config.(buck || continue_capture || infer_is_clang || infer_is_javac || reactive_mode) [Driver.clean_results_dir ()]). *)
) buck && flavors)
|| not
( Driver.(equal_mode driver_mode Analyze)
|| Config.(continue_capture || infer_is_clang || infer_is_javac || reactive_mode) )
then ResultsDir.remove_results_dir () ; then ResultsDir.remove_results_dir () ;
ResultsDir.create_results_dir () ResultsDir.create_results_dir ()
| Explore -> | Explore ->

@ -0,0 +1,55 @@
# Copyright (c) 2017 - present Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
TESTS_DIR = ../..
INFER_OUT = infer-out
include $(TESTS_DIR)/differential.make
DIFFERENTIAL_ARGS = --differential-filter-files changed_files.txt
include ../../differential.make
BUCK_TARGET = //src:hello
INFER_OPTIONS = $(DIFFERENTIAL_ARGS) --flavors --reactive --debug-exceptions
SRC_DIR = $(CURDIR)/../codetoanalyze
.PHONY: compare_reports
compare_reports: current.exp.test previous.exp.test
$(QUIET)$(call check_no_diff,current.exp,current.exp.test)
$(QUIET)$(call check_no_diff,previous.exp,previous.exp.test)
.PHONY: replace_reports
replace_reports: current.exp.test previous.exp.test
$(COPY) current.exp.test current.exp
$(COPY) previous.exp.test previous.exp
current.exp.test: $(CURRENT_REPORT)
$(QUIET)$(INFER_BIN) report -o $(<D) \
--from-json-report $(CURRENT_DIR)/report.json \
--issues-tests current.exp.test
previous.exp.test: $(PREVIOUS_REPORT)
$(QUIET)$(INFER_BIN) report -o $(<D) \
--from-json-report $(PREVIOUS_DIR)/report.json \
--issues-tests previous.exp.test
test: compare_reports
print: current.exp.test previous.exp.test
replace: replace_reports
$(CURRENT_REPORT):
$(QUIET)$(REMOVE_DIR) buck-out
$(QUIET)$(COPY) $(SRC_DIR)/some_bugs.c src/hello.c
$(QUIET)$(call silent_on_success,Running Buck diff analysis: current,\
$(INFER_BIN) $(INFER_OPTIONS) run --results-dir $(CURRENT_DIR) -- \
$(BUCK) build --no-cache $(BUCK_TARGET))
$(PREVIOUS_REPORT):
$(QUIET)$(COPY) $(SRC_DIR)/some_different_bugs.c src/hello.c
$(QUIET)$(call silent_on_success,Running Buck diff analysis: previous,\
$(INFER_BIN) $(INFER_OPTIONS) run --results-dir $(PREVIOUS_DIR) -- \
$(BUCK) build --no-cache $(BUCK_TARGET))

@ -0,0 +1,3 @@
src/hello.c, test1, 2, NULL_DEREFERENCE, [start of procedure test1()]
src/hello.c, test2, 2, NULL_DEREFERENCE, [start of procedure test2(),start of procedure nullify()]
src/hello2.c, test_hello2, 2, NULL_DEREFERENCE, [start of procedure test_hello2()]

@ -0,0 +1 @@
MEMORY_LEAK, src/hello.c, test3, 3, test3.8ad8757baa8564dc136c1e07507f4a98, test3

@ -0,0 +1 @@
NULL_DEREFERENCE, src/hello.c, test2, 2, test2.ad0234829205b9033196ba818f7a872b, test2

@ -0,0 +1 @@
NULL_DEREFERENCE, src/hello.c, test1, 2, test1.5a105e8b9d40e1329780d62ea2265d8a, test1

@ -0,0 +1,3 @@
src/hello.c, test1, 2, NULL_DEREFERENCE, [start of procedure test1()]
src/hello.c, test3, 3, MEMORY_LEAK, [start of procedure test3(),Condition is true]
src/hello2.c, test_hello2, 2, NULL_DEREFERENCE, [start of procedure test_hello2()]

@ -0,0 +1,6 @@
cxx_library(
name = 'hello',
srcs = [
'hello.c', 'hello2.c',
],
)

@ -0,0 +1,15 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <stdlib.h>
void test_hello2() {
int* s = NULL;
*s = 42;
}

@ -10,7 +10,7 @@ ROOT_DIR = $(TESTS_DIR)/../..
ANALYZER = checkers ANALYZER = checkers
BUCK_TARGET = //src:hello BUCK_TARGET = //src:hello
SOURCES = $(wildcard src/hello.c) SOURCES = src/hello.c src/hello2.c
OBJECTS = buck-out/gen/src/hello\#compile-hello.c.o1f717d69,default/hello.c.o OBJECTS = buck-out/gen/src/hello\#compile-hello.c.o1f717d69,default/hello.c.o
INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(TESTS_DIR) INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(TESTS_DIR)
INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests
@ -18,7 +18,7 @@ CLEAN_EXTRA = buck-out
include $(TESTS_DIR)/infer.make include $(TESTS_DIR)/infer.make
$(OBJECTS): $(JAVA_SOURCE_FILES) $(OBJECTS): $(SOURCES)
$(QUIET)$(call silent_on_success,Compiling Buck flavors tests,\ $(QUIET)$(call silent_on_success,Compiling Buck flavors tests,\
NO_BUCKD=1 $(BUCK) build --no-cache $(BUCK_TARGET)) NO_BUCKD=1 $(BUCK) build --no-cache $(BUCK_TARGET))

@ -15,8 +15,8 @@ EXPECTED_TEST_OUTPUT = introduced.exp.test
INFERPRINT_ISSUES_FIELDS = \ INFERPRINT_ISSUES_FIELDS = \
"bug_type,file,procedure,line_offset,procedure_id,procedure_id_without_crc" "bug_type,file,procedure,line_offset,procedure_id,procedure_id_without_crc"
CURRENT_DIR = infer-current CURRENT_DIR = infer-out-current
PREVIOUS_DIR = infer-previous PREVIOUS_DIR = infer-out-previous
CURRENT_REPORT = $(CURRENT_DIR)/report.json CURRENT_REPORT = $(CURRENT_DIR)/report.json
PREVIOUS_REPORT = $(PREVIOUS_DIR)/report.json PREVIOUS_REPORT = $(PREVIOUS_DIR)/report.json

Loading…
Cancel
Save