Skip to content

Commit 3a4788c

Browse files
authored
Merge pull request diffblue#455 from diffblue/smowton/merge/develop-2018-06-13
SEC-461: Merge from develop, 2018-06-13
2 parents 1d89f1d + 3da787a commit 3a4788c

File tree

789 files changed

+10833
-5781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

789 files changed

+10833
-5781
lines changed

cbmc/.gitignore

+7-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ src/ansi-c/gcc_builtin_headers_mips.inc
4949
src/ansi-c/gcc_builtin_headers_power.inc
5050
src/ansi-c/gcc_builtin_headers_ubsan.inc
5151
src/ansi-c/windows_builtin_headers.inc
52-
jbmc/src/java_bytecode/java_core_models.inc
52+
src/cpp/cprover_library.inc
5353

5454
# regression/test files
5555
*.out
@@ -123,9 +123,13 @@ src/ansi-c/file_converter
123123
src/ansi-c/file_converter.exe
124124
src/ansi-c/library/converter
125125
src/ansi-c/library/converter.exe
126-
jbmc/src/java_bytecode/converter
127-
jbmc/src/java_bytecode/converter.exe
126+
jbmc/src/java_bytecode/library/converter.exe
127+
jbmc/src/java_bytecode/library/converter
128+
jbmc/src/java_bytecode/library/core-models.jar
129+
jbmc/src/java_bytecode/library/classes
130+
jbmc/src/java_bytecode/library/src
128131
build/
132+
dist/
129133

130134
*.pyc
131135

cbmc/.travis.yml

+28-12
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,35 @@ jobs:
4646
before_cache:
4747

4848
- stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
49-
env: NAME="DOXYGEN-CHECK"
49+
env:
50+
NAME: "DOXYGEN-CHECK"
51+
DOXYGEN_VERSION: "1.8.14"
5052
addons:
5153
apt:
5254
sources:
5355
- sourceline: 'deb http://packages.cloud.google.com/apt cloud-sdk-trusty main'
5456
key_url: 'https://packages.cloud.google.com/apt/doc/apt-key.gpg'
5557
packages:
56-
- doxygen
58+
- cmake
5759
- google-cloud-sdk
60+
cache:
61+
directories:
62+
- ${TRAVIS_BUILD_DIR}/doxygen/build/bin
5863
install:
59-
script: scripts/travis_doxygen.sh
64+
- |
65+
# Build doxygen if it is not in Travis cache
66+
if ! [ -x doxygen/build/bin/doxygen ]
67+
then
68+
mkdir -p doxygen/build \
69+
&& wget http://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYGEN_VERSION}.src.tar.gz -O- | tar -xz --strip-components=1 --directory doxygen \
70+
&& ( cd doxygen/build && cmake .. ) \
71+
&& make -j4 -C doxygen/build
72+
fi
73+
- export PATH="$PATH:${TRAVIS_BUILD_DIR}/doxygen/build/bin"
74+
script:
75+
- echo $PATH
76+
- doxygen --version
77+
- scripts/travis_doxygen.sh
6078
before_cache:
6179
after_success:
6280
# Google Cloud Integration
@@ -222,8 +240,9 @@ jobs:
222240

223241
# Run Coverity
224242
- stage: Test different OS/CXX/Flags
243+
if: type = cron
225244
os: linux
226-
sudo: required
245+
sudo: false
227246
compiler: gcc
228247
cache: ccache
229248
addons:
@@ -238,16 +257,11 @@ jobs:
238257
name: "diffblue/cbmc"
239258
description: "Travis build of ${TRAVIS_COMMIT}"
240259
notification_email: "[email protected]"
260+
build_command_prepend: "make -C jbmc/src java-models-library-download"
241261
build_command_prepend: "make -C src minisat2-download"
242262
build_command: "make -C src -j2; make -C jbmc/src -j2"
243263
branch_pattern: "develop"
244264
before_install:
245-
- |
246-
if [[ "${TRAVIS_EVENT_TYPE}" != "cron" ]]
247-
then
248-
echo "This is not a cron build and build is not needed."
249-
travis_terminate 0
250-
fi
251265
- mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc
252266
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 90
253267
- g++ --version
@@ -264,10 +278,12 @@ jobs:
264278
install:
265279
- ccache -z
266280
- ccache --max-size=1G
281+
- make -C jbmc/src java-models-library-download
267282
- make -C src minisat2-download
268283
- make -C src boost-download
269284
- make -C src/ansi-c library_check
270-
- make -C src "CXX=${COMPILER} -DUSE_BOOST ${EXTRA_CXXFLAGS}" -j3
285+
- make -C src/cpp library_check
286+
- make -C src "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j3
271287
- make -C src "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j3 clobber.dir memory-models.dir
272288
- make -C jbmc/src "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j3
273289

@@ -287,9 +303,9 @@ notifications:
287303
webhooks:
288304
urls:
289305
- http://dashboard.diffblue.com/api/travis-webhooks
306+
- https://us-central1-dev-user-joelallred.cloudfunctions.net/trigger-testgen-from-cbmc
290307
on_success: always
291308
on_failure: always
292309
on_start: never
293310
on_cancel: never
294311
on_error: always
295-

cbmc/COMPILING.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution.
2727
```
2828
yum install gcc gcc-c++ flex bison perl-libwww-perl patch devtoolset-6 java-1.7.0-openjdk-devel
2929
```
30-
Note that you need g++ version 4.9 or newer.
30+
Note that you need g++ version 5.0 or newer.
3131

32-
To compile JBMC, you additionally need the JDK:
33-
On Debian-like distributions, do
32+
To compile JBMC, you additionally need the JDK and the java-models-library.
33+
34+
For the JDK, on Debian-like distributions, do
3435
```
3536
apt-get install openjdk-7-jdk
3637
```
3738
On Red Hat/Fedora or derivates, do
3839
```
3940
yum install java-1.7.0-openjdk-devel
4041
```
42+
For the models library, do
43+
```
44+
make -C jbmc/src java-models-library-download
45+
```
4146

4247
2. As a user, get the CBMC source via
4348
```
@@ -95,7 +100,7 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution.
95100
```
96101
That should do it. To run, you will need
97102
```
98-
export LD_LIBRARY_PATH=/usr/gcc/4.9/lib
103+
export LD_LIBRARY_PATH=/usr/gcc/5.0/lib
99104
```
100105

101106
# COMPILATION ON FREEBSD 11

cbmc/appveyor.yml

+5-19
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,17 @@ install:
4242
& 7z x minisat2_2.2.1.orig.tar.gz
4343
&7z x minisat2_2.2.1.orig.tar
4444
}
45+
if (!(Test-Path java-models-library-master\.gitignore)) {
46+
& appveyor downloadfile https://github.com/diffblue/java-models-library/archive/master.zip -FileName jml.zip
47+
& 7z x jml.zip
48+
}
4549
cd ..
4650
4751
cache: deps
4852

4953
build_script:
5054
- cmd: |
55+
cp -r deps/java-models-library-master/src jbmc/src/java_bytecode/library
5156
cp -r deps/minisat2-2.2.1 minisat-2.2.1
5257
patch -d minisat-2.2.1 -p1 < scripts/minisat-2.2.1-patch
5358
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
@@ -59,18 +64,9 @@ test_script:
5964
- cmd: |
6065
cd regression
6166
rem HACK disable failing tests
62-
rmdir /s /q ansi-c\arch_flags_mcpu_bad
63-
rmdir /s /q ansi-c\arch_flags_mcpu_good
64-
rmdir /s /q ansi-c\arch_flags_mthumb_bad
65-
rmdir /s /q ansi-c\arch_flags_mthumb_good
6667
rmdir /s /q ansi-c\Forward_Declaration2
6768
rmdir /s /q ansi-c\Incomplete_Type1
68-
rmdir /s /q ansi-c\Union_Padding1
6969
rmdir /s /q ansi-c\Universal_characters1
70-
rmdir /s /q ansi-c\function_return1
71-
rmdir /s /q ansi-c\gcc_attributes7
72-
rmdir /s /q ansi-c\struct6
73-
rmdir /s /q ansi-c\struct7
7470
rmdir /s /q cbmc\Malloc23
7571
rmdir /s /q cbmc\byte_update2
7672
rmdir /s /q cbmc\byte_update3
@@ -80,16 +76,6 @@ test_script:
8076
rmdir /s /q cbmc\byte_update7
8177
rmdir /s /q cbmc\pipe1
8278
rmdir /s /q cbmc\unsigned___int128
83-
rmdir /s /q cbmc-cpp
84-
rmdir /s /q cpp\Decltype1
85-
rmdir /s /q cpp\Decltype2
86-
rmdir /s /q cpp\Function_Overloading1
87-
rmdir /s /q cpp\enum2
88-
rmdir /s /q cpp\enum7
89-
rmdir /s /q cpp\enum8
90-
rmdir /s /q cpp\nullptr1
91-
rmdir /s /q cpp\sizeof1
92-
rmdir /s /q cpp\static_assert1
9379
rmdir /s /q goto-gcc
9480
rmdir /s /q goto-instrument\slice08
9581
cd ..

cbmc/buildspec-windows.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
commands:
6+
- choco install cyg-get -y --no-progress
7+
- cyg-get bash patch bison flex make wget perl
8+
9+
build:
10+
commands:
11+
- 'C:\tools\cygwin\bin\sed -i "s/BUILD_ENV[ ]*=.*/BUILD_ENV = MSVC/" src/config.inc'
12+
- |
13+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
14+
C:\tools\cygwin\bin\bash -c "make -C src minisat2-download DOWNLOADER=wget"
15+
16+
- |
17+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
18+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C src" '
19+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C unit all" '
20+
21+
- |
22+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
23+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C jbmc/src" '
24+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C jbmc/unit all ; exit 0" '
25+
26+
post_build:
27+
commands:
28+
- |
29+
cd regression
30+
# HACK disable failing tests
31+
Remove-Item ansi-c\Forward_Declaration2 -Force -Recurse
32+
Remove-Item ansi-c\Incomplete_Type1 -Force -Recurse
33+
Remove-Item cbmc\Malloc23 -Force -Recurse
34+
Remove-Item cbmc\byte_update2 -Force -Recurse
35+
Remove-Item cbmc\byte_update3 -Force -Recurse
36+
Remove-Item cbmc\byte_update4 -Force -Recurse
37+
Remove-Item cbmc\byte_update5 -Force -Recurse
38+
Remove-Item cbmc\byte_update6 -Force -Recurse
39+
Remove-Item cbmc\byte_update7 -Force -Recurse
40+
Remove-Item cbmc\pipe1 -Force -Recurse
41+
Remove-Item cbmc\unsigned___int128 -Force -Recurse
42+
Remove-Item cpp -Force -Recurse
43+
Remove-Item cbmc-cpp -Force -Recurse
44+
Remove-Item goto-gcc -Force -Recurse
45+
Remove-Item systemc -Force -Recurse
46+
Remove-Item goto-instrument\slice08 -Force -Recurse
47+
Remove-Item goto-analyzer/constant_propagation_nondet_rounding_mode -Force -Recurse
48+
cd ..
49+
50+
- |
51+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
52+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C regression test" '
53+
54+
- |
55+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
56+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C unit test" '
57+
58+
- |
59+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
60+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C jbmc/regression test ; exit 0" '
61+
62+
- |
63+
$env:Path = "C:\tools\cygwin\bin;$env:Path"
64+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C jbmc/unit test ; exit 0" '
65+
66+
artifacts:
67+
files:
68+
69+
cache:
70+
paths:

cbmc/buildspec.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ phases:
1313
build:
1414
commands:
1515
- echo Build started on `date`
16+
- make -C jbmc/src java-models-library-download
1617
- (cd src ; make minisat2-download)
1718
- (cd src ; make CXX="ccache g++" -j2)
1819
- (cd regression ; make test)

cbmc/jbmc/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ About
44
=====
55

66
JBMC is a Bounded Model Checker for Java programs. It supports
7-
checking for runtime exceptions and user-definde assertions.
7+
checking for runtime exceptions and user-defined assertions.
88
The verification is performed by unwinding the loops in the program
99
and passing the resulting equation to a decision procedure.
1010

@@ -30,8 +30,10 @@ Compilation
3030
To compile you need to run the command:
3131

3232
```bash
33+
make -C jbmc/src java-models-library-download
3334
make -C jbmc/src
3435
```
36+
3537
Output
3638
======
3739

Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Must be compiled with CProverString:
2+
// javac Test.java ../cprover/CProverString.java
3+
public class Test {
4+
5+
// Reference implementation
6+
public static boolean referenceStartsWith(String s, String prefix, int offset) {
7+
if (offset < 0 || offset > s.length() - prefix.length()) {
8+
return false;
9+
}
10+
11+
for (int i = 0; i < prefix.length(); i++) {
12+
if (org.cprover.CProverString.charAt(s, offset + i)
13+
!= org.cprover.CProverString.charAt(prefix, i)) {
14+
return false;
15+
}
16+
}
17+
return true;
18+
}
19+
20+
public static boolean check(String s, String t, int offset) {
21+
// Filter out null strings
22+
if(s == null || t == null) {
23+
return false;
24+
}
25+
26+
// Act
27+
final boolean result = s.startsWith(t, offset);
28+
29+
// Assert
30+
final boolean referenceResult = referenceStartsWith(s, t, offset);
31+
assert(result == referenceResult);
32+
33+
// Check reachability
34+
assert(result == false);
35+
return result;
36+
}
37+
38+
public static boolean checkDet() {
39+
boolean result = false;
40+
result = "foo".startsWith("foo", 0);
41+
assert(result);
42+
result = "foo".startsWith("f", -1);
43+
assert(!result);
44+
result = "foo".startsWith("oo", 1);
45+
assert(result);
46+
result = "foo".startsWith("f", 1);
47+
assert(!result);
48+
result = "foo".startsWith("bar", 0);
49+
assert(!result);
50+
result = "foo".startsWith("oo", 2);
51+
assert(!result);
52+
assert(false);
53+
return result;
54+
}
55+
56+
public static boolean checkNonDet(String s) {
57+
// Filter
58+
if (s == null) {
59+
return false;
60+
}
61+
62+
// Act
63+
final boolean result = s.startsWith(s, 1);
64+
65+
// Assert
66+
assert(!result);
67+
68+
// Check reachability
69+
assert(false);
70+
return result;
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
--refine-strings --string-max-input-length 10 --unwind 10 --function Test.check
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 31 .*: SUCCESS
7+
assertion at file Test.java line 34 .*: FAILURE
8+
--

0 commit comments

Comments
 (0)