Skip to content

Commit

Permalink
Bug 1479503: Check infer in ./mach static-analysis autotest. r=nalexa…
Browse files Browse the repository at this point in the history
…nder

Adds infer to ./mach static-analysis autotest.

Differential Revision: https://phabricator.services.mozilla.com/D4547
  • Loading branch information
Robert Bartlensky committed Sep 12, 2018
1 parent b26730b commit 4435ef3
Show file tree
Hide file tree
Showing 30 changed files with 1,242 additions and 106 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ exclude =
testing/mochitest/pywebsocket,
tools/lint/test/files,
build/build-infer/build-infer.py,
tools/infer/test/*.configure,
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ _OPT\.OBJ/

# Gradle cache.
^.gradle/
^tools/infer/test/.gradle/

# Local Gradle configuration properties.
^local.properties$
Expand Down
10 changes: 10 additions & 0 deletions moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,16 @@ set_config('MAKENSISU_FLAGS', nsis_flags)

check_prog('7Z', ('7z', '7za'), allow_missing=True, when=target_is_windows)

@depends(host)
def include_infer_autotest(host):
# Do not include autotest configuration on Windows or macos
# because infer is not available there
if host.os in ['WINNT', 'OSX']:
return None
return 'tools/infer/test/moz.configure'

include(include_infer_autotest)

# Fallthrough to autoconf-based configure
include('build/moz.configure/old.configure')

Expand Down
234 changes: 176 additions & 58 deletions python/mozbuild/mozbuild/mach_commands.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions taskcluster/ci/docker-image/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ jobs:
fetch:
symbol: I(fetch)
parent: debian9-base
infer-build:
symbol: I(infer)
parent: debian9-base
static-analysis-build:
symbol: I(static-analysis-build)
parent: android-build
mingw32-build:
symbol: I(mingw)
parent: debian9-base
Expand Down
4 changes: 4 additions & 0 deletions taskcluster/ci/static-analysis-autotest/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
description: "Linux64 Debug Static Analysis Autotest"
index:
job-name: linux64-st-autotest-debug
worker:
docker-image: {in-tree: static-analysis-build}
env:
PERFHERDER_EXTRA_OPTIONS: static-analysis-autotest
treeherder:
platform: linux64/debug
worker-type: aws-provisioner-v1/gecko-t-linux-large
Expand Down
2 changes: 1 addition & 1 deletion taskcluster/ci/toolchain/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ linux64-infer:
tier: 1
worker-type: aws-provisioner-v1/gecko-{level}-b-linux
worker:
docker-image: {in-tree: infer-build}
docker-image: {in-tree: static-analysis-build}
max-run-time: 3600
run:
using: toolchain-script
Expand Down
30 changes: 0 additions & 30 deletions taskcluster/docker/infer-build/Dockerfile

This file was deleted.

58 changes: 58 additions & 0 deletions taskcluster/docker/static-analysis-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# %ARG DOCKER_IMAGE_PARENT
FROM $DOCKER_IMAGE_PARENT
MAINTAINER Robert Bartlensky <[email protected]>

VOLUME /builds/worker/checkouts
VOLUME /builds/worker/workspace
VOLUME /builds/worker/tooltool-cache

ENV XZ_OPT=-T0

RUN apt-get update && \
apt-get install \
autoconf2.13 \
automake \
bison \
bzip2 \
cmake \
flex \
curl \
opam \
libsqlite3-dev \
file \
gawk \
gcc-multilib \
gnupg \
libc6-dev \
openjdk-8-jdk-headless \
pkg-config \
patch \
p7zip-full \
procps \
python-pip \
python-setuptools \
python-virtualenv \
rsync \
screen \
tar \
unzip \
uuid \
valgrind \
wget \
yasm \
zip \
zlib1g-dev \
x11-utils \
xvfb \
linux-libc-dev \
libdbus-glib-1-dev \
libfontconfig1-dev \
libfreetype6-dev \
libgconf2-dev \
libgtk-3-dev \
libgtk2.0-dev \
libpango1.0-dev \
libpulse-dev \
libx11-xcb-dev \
libxt-dev \
lib32z1
1 change: 0 additions & 1 deletion testing/mozharness/mozharness/base/script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#!/usr/bin/env python
# ***** BEGIN LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
30 changes: 20 additions & 10 deletions testing/mozharness/mozharness/mozilla/building/buildbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,13 +1226,15 @@ def build(self):
def static_analysis_autotest(self):
"""Run mach static-analysis autotest, in order to make sure we dont regress"""
self.preflight_build()
self._run_mach_command_in_build_env(['static-analysis', 'autotest', '--intree-tool'])
self._run_mach_command_in_build_env(['configure'])
self._run_mach_command_in_build_env(['static-analysis', 'autotest',
'--intree-tool'],
use_subprocess=True)

def _run_mach_command_in_build_env(self, args):
def _run_mach_command_in_build_env(self, args, use_subprocess=False):
"""Run a mach command in a build context."""
env = self.query_build_env()
env.update(self.query_mach_build_env())

dirs = self.query_abs_dirs()

if 'MOZILLABUILD' in os.environ:
Expand All @@ -1245,13 +1247,21 @@ def _run_mach_command_in_build_env(self, args):
else:
mach = [sys.executable, 'mach']

return_code = self.run_command(
command=mach + ['--log-no-times'] + args,
cwd=dirs['abs_src_dir'],
env=env,
output_timeout=self.config.get('max_build_output_timeout', 60 * 40)
)

# XXX See bug 1483883
# Work around an interaction between Gradle and mozharness
# Not using `subprocess` causes gradle to hang
if use_subprocess:
import subprocess
return_code = subprocess.call(mach + ['--log-no-times'] + args,
env=env, cwd=dirs['abs_src_dir'])
else:
return_code = self.run_command(
command=mach + ['--log-no-times'] + args,
cwd=dirs['abs_src_dir'],
env=env,
output_timeout=self.config.get('max_build_output_timeout',
60 * 40)
)
if return_code:
self.return_code = self.worst_level(
EXIT_STATUS_DICT[TBPL_FAILURE], self.return_code,
Expand Down
14 changes: 11 additions & 3 deletions tools/infer/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@ target: obj-x86_64-pc-linux-gnu
platforms:
- linux64
infer_checkers:
# no issues were ever trigger by this
- name: check-nullable
publish: !!bool no
- name: biabduction
publish: !!bool yes
# very very noisy
# it could be useful, but it won't be part of the default enabled checkers
- name: eradicate
publish: !!bool no
# hard to use, not useful
- name: quandary
publish: !!bool yes
publish: !!bool no
- name: starvation
publish: !!bool yes
# experimental
- name: litho
publish: !!bool yes
publish: !!bool no
- name: racerd
publish: !!bool yes
# I think this is only for c++, can't trigger these errors in Java
- name: liveness
publish: !!bool yes
publish: !!bool no
# Third party files from mozilla-central
third_party: tools/rewriting/ThirdPartyPaths.txt
23 changes: 23 additions & 0 deletions tools/infer/test/autotest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apply plugin: 'java'

repositories {
mavenCentral()
}

dependencies {
compile "com.google.code.findbugs:jsr305:3.0.2"
}

def createSingleTask = { name ->
task("compileInferTest${name}", type: JavaCompile) {
source = fileTree(dir: '.', include: "src/main/java/${name}.java")
classpath = project.configurations.compileClasspath
destinationDir = file("${topobjdir}/gradle/build/tools/infer/test/autotest")
}
}

createSingleTask('Biabduction')
createSingleTask('Checkers')
createSingleTask('Eradicate')
createSingleTask('Racerd')
createSingleTask('Starvation')
22 changes: 22 additions & 0 deletions tools/infer/test/autotest/src/main/java/Biabduction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import javax.annotation.Nullable;
import java.util.List;

public class Biabduction {
private String get() { return null; }

public void f1() {
get().length(); // error
}

public void f2() {
try {
get().length(); // error
} catch (NullPointerException e) {

}
}
}
114 changes: 114 additions & 0 deletions tools/infer/test/autotest/src/main/java/Biabduction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[
{
"bug_class": "PROVER",
"bug_trace": [
{
"column_number": -1,
"description": "start of procedure f1()",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 0,
"line_number": 11
},
{
"column_number": -1,
"description": "",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 0,
"line_number": 12
},
{
"column_number": -1,
"description": "start of procedure get()",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 1,
"line_number": 9
},
{
"column_number": -1,
"description": "return from a call to String Biabduction.get()",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 1,
"line_number": 9
},
{
"column_number": -1,
"description": "",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 0,
"line_number": 12
}
],
"bug_type": "NULL_DEREFERENCE",
"bug_type_hum": "Null Dereference",
"censored_reason": "",
"column": -1,
"file": "autotest/src/main/java/Biabduction.java",
"hash": "918d7eaedf45f651f04c55554c72478c",
"key": "Biabduction.java|f1|NULL_DEREFERENCE",
"kind": "ERROR",
"line": 12,
"node_key": "9afcdcc9d4253c36267a0d34b98c337d",
"procedure": "void Biabduction.f1()",
"procedure_id": "Biabduction.f1():void.4b49520e7621606a0d5661886ff0b098",
"procedure_start_line": 11,
"qualifier": "object returned by `get(this)` could be null and is dereferenced at line 12.",
"severity": "HIGH",
"visibility": "user"
},
{
"bug_class": "PROVER",
"bug_trace": [
{
"column_number": -1,
"description": "start of procedure f2()",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 0,
"line_number": 15
},
{
"column_number": -1,
"description": "",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 0,
"line_number": 17
},
{
"column_number": -1,
"description": "start of procedure get()",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 1,
"line_number": 9
},
{
"column_number": -1,
"description": "return from a call to String Biabduction.get()",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 1,
"line_number": 9
},
{
"column_number": -1,
"description": "",
"filename": "autotest/src/main/java/Biabduction.java",
"level": 0,
"line_number": 17
}
],
"bug_type": "NULL_DEREFERENCE",
"bug_type_hum": "Null Dereference",
"censored_reason": "",
"column": -1,
"file": "autotest/src/main/java/Biabduction.java",
"hash": "bc952ce8bad58dac5cb6672dc3150524",
"key": "Biabduction.java|f2|NULL_DEREFERENCE",
"kind": "ERROR",
"line": 17,
"node_key": "9afcdcc9d4253c36267a0d34b98c337d",
"procedure": "void Biabduction.f2()",
"procedure_id": "Biabduction.f2():void.41c05a632eb912a458482c1e2e4dcbb4",
"procedure_start_line": 15,
"qualifier": "object returned by `get(this)` could be null and is dereferenced at line 17.",
"severity": "HIGH",
"visibility": "user"
}
]
Loading

0 comments on commit 4435ef3

Please sign in to comment.