Skip to content

Commit 6c3b46b

Browse files
committed
Merge commit '174d261a963adcfb058d8be83207b57701acdaf7' into CBMC_merge_2018-06-29
# Conflicts: # cbmc/jbmc/src/java_bytecode/java_bytecode_language.cpp # cbmc/jbmc/src/java_bytecode/replace_java_nondet.cpp # cbmc/jbmc/unit/java_bytecode/java_replace_nondet/replace_nondet.cpp # cbmc/src/analyses/call_graph_helpers.cpp # cbmc/src/analyses/call_graph_helpers.h
2 parents 55ff129 + 174d261 commit 6c3b46b

File tree

101 files changed

+1218
-437
lines changed

Some content is hidden

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

101 files changed

+1218
-437
lines changed

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks-illegal-state/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
KNOWNBUG
22
Sync.class
3-
--lazy-methods --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
3+
--lazy-methods --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --java-threading
44
^VERIFICATION SUCCESSFUL$
55
^EXIT=0$
66
^SIGNAL=0$

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks-null-throw/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
KNOWNBUG
22
Sync.class
3-
--cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
3+
--cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --java-threading
44
^VERIFICATION SUCCESSFUL$
55
--
66
^warning: ignoring

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks-throw/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
KNOWNBUG
22
Sync.class
3-
--cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --lazy-methods
3+
--cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --lazy-methods --java-threading
44
^VERIFICATION SUCCESSFUL$
55
--
66
^warning: ignoring
Binary file not shown.

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks/A.java

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ public void me0()
1414
}
1515
}
1616

17+
// expected verification success
18+
public static void aStatic() throws java.io.IOException
19+
{
20+
Object _lock = new Object();
21+
try
22+
{
23+
synchronized (_lock)
24+
{
25+
if(true)
26+
throw new java.io.IOException();
27+
}
28+
}
29+
catch (java.io.IOException e)
30+
{
31+
return;
32+
}
33+
assert false; // unreachable
34+
}
35+
1736
// expected verification success
1837
// --
1938
// base-case, no synchronization
Binary file not shown.

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks/test1.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
A.class
3-
--function 'A.me0:()V' --lazy-methods --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --show-goto-functions
3+
--function 'A.me0:()V' --lazy-methods --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --show-goto-functions --java-threading
44
ATOMIC_BEGIN
55
ATOMIC_END
66
--

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks/test2.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
A.class
3-
--function 'A.me0:()V' --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
3+
--function 'A.me0:()V' --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --java-threading
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

cbmc/jbmc/regression/jbmc-concurrency/synchronized-blocks/test3.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
A.class
3-
--function 'A.me0:()V' --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --lazy-methods
3+
--function 'A.me0:()V' --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar` --lazy-methods --java-threading
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
A.class
3+
--function 'A.aStatic' --lazy-methods
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Tests that throwing an exception from a synchronization blocks does not cause reachability issues when the java-threading flag is not specified.
10+
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class Test {
2+
3+
public static void testme(StringBuilder builder, StringBuffer buffer) {
4+
5+
}
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang;
2+
3+
public class AbstractStringBuilder implements CharSequence {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang;
2+
3+
interface CharSequence {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang;
2+
3+
public class String implements CharSequence {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang;
2+
3+
public class StringBuffer extends AbstractStringBuilder {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang;
2+
3+
public class StringBuilder extends AbstractStringBuilder {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.testme
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
type mismatch
9+
--
10+
Before cbmc#2472 this would assume that StringBuilder's direct parent was
11+
java.lang.Object, causing a type mismatch when --refine-strings was not in use
12+
(which at the time would assume that parent-child relationship)

cbmc/jbmc/regression/jbmc-strings/StringConcat_StringII/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
Test.class
3-
--refine-strings --string-max-length 100 --string-max-input-length 4 --verbosity 10 --unwind 5 Test.class --function Test.testSuccess
3+
--refine-strings --string-max-length 100 --string-max-input-length 4 --verbosity 10 --unwind 5 --function Test.testSuccess
44
^EXIT=0$
55
^SIGNAL=0$
66
assertion at file Test.java line 23 .*: SUCCESS

cbmc/jbmc/regression/jbmc-strings/StringConcat_StringII/test_fail.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
Test.class
3-
--refine-strings --string-max-length 10000 --verbosity 10 Test.class --function Test.testFail
3+
--refine-strings --string-max-length 10000 --verbosity 10 --function Test.testFail
44
^EXIT=10$
55
^SIGNAL=0$
66
assertion at file Test.java line 38 .*: FAILURE

cbmc/jbmc/regression/jbmc-strings/StringDependencies/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
Test.class
3-
--refine-strings --string-max-length 1000 --string-max-input-length 100 --verbosity 10 Test.class --function Test.test
3+
--refine-strings --string-max-length 1000 --string-max-input-length 100 --verbosity 10 --function Test.test
44
^EXIT=0$
55
^SIGNAL=0$
66
assertion at file Test.java line 20 .*: SUCCESS
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
public class Test {
2+
3+
public static void testme(StringBuilder builder, StringBuffer buffer, String str) {
4+
5+
// In this test the versions of String, StringBuilder and
6+
// StringBuffer.class supplied have fields beyond the expected situation
7+
// of either no fields at all (without --refine-strings) or only 'length'
8+
// and 'data' (with --refine-strings). We check they have been nondet-
9+
// initialized as expected by making sure we can reach the final
10+
// 'assert false'.
11+
12+
if(str != null &&
13+
builder != null &&
14+
buffer != null &&
15+
str.a != null &&
16+
builder.i != null &&
17+
buffer.i != null &&
18+
str.a.x >= 5 &&
19+
str.a.y <= -10.0f &&
20+
builder.d >= 100.0 &&
21+
buffer.b == true) {
22+
23+
assert builder instanceof StringBuilder;
24+
assert buffer instanceof StringBuffer;
25+
assert str instanceof String;
26+
27+
assert str.a instanceof A;
28+
assert builder.i instanceof Integer;
29+
assert buffer.i instanceof Integer;
30+
31+
assert false;
32+
}
33+
34+
}
35+
36+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package java.lang;
2+
3+
public class A {
4+
5+
public int x;
6+
public float y;
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package java.lang;
2+
3+
public class AbstractStringBuilder implements CharSequence {
4+
5+
public Integer i;
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang;
2+
3+
interface CharSequence {
4+
5+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package java.lang;
2+
3+
public class String implements CharSequence {
4+
5+
public A a;
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package java.lang;
2+
3+
public class StringBuffer extends AbstractStringBuilder {
4+
5+
public boolean b;
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package java.lang;
2+
3+
public class StringBuilder extends AbstractStringBuilder {
4+
5+
public double d;
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
Test.class
3+
--function Test.testme
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 23 .* SUCCESS
7+
assertion at file Test.java line 24 .* SUCCESS
8+
assertion at file Test.java line 25 .* SUCCESS
9+
assertion at file Test.java line 27 .* SUCCESS
10+
assertion at file Test.java line 28 .* SUCCESS
11+
assertion at file Test.java line 29 .* SUCCESS
12+
assertion at file Test.java line 31 .* FAILURE
13+
--
14+
type mismatch

cbmc/jbmc/regression/jbmc-strings/max-length-generic-array/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
IntegerTests.class
3-
-refine-strings --string-max-length 100 IntegerTests.class --function IntegerTests.testMySet --cover location
3+
-refine-strings --string-max-length 100 --function IntegerTests.testMySet --cover location
44
^EXIT=0$
55
^SIGNAL=0$
66
coverage.* line 12 function java::IntegerTests.testMySet.* bytecode-index 1 .* SATISFIED

cbmc/jbmc/regression/jbmc-strings/max-length-generic-array/test_gen.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
IntegerTests.class
3-
-refine-strings --string-max-length 100 IntegerTests.class --function IntegerTests.testMyGenSet --cover location
3+
-refine-strings --string-max-length 100 --function IntegerTests.testMyGenSet --cover location
44
^EXIT=0$
55
^SIGNAL=0$
66
coverage.* line 4 function java::IntegerTests.testMyGenSet.* bytecode-index 1 .* SATISFIED

cbmc/jbmc/regression/jbmc/package_friendly1/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE symex-driven-lazy-loading-expected-failure
22
main.class
3-
package_friendly1.class package_friendly2.class --show-goto-functions
3+
--java-load-class package_friendly1 --java-load-class package_friendly2 --show-goto-functions
44
^main[.]main[\(].*[\)].*$
55
^package_friendly2[.]operation2[\(][\)].*$
66
^EXIT=0$

cbmc/jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,6 @@ codet java_bytecode_convert_methodt::convert_instructions(
10321032
}
10331033

10341034
if(i_it->statement=="athrow" ||
1035-
i_it->statement=="monitorenter" ||
1036-
i_it->statement=="monitorexit" ||
10371035
i_it->statement=="putfield" ||
10381036
i_it->statement=="getfield" ||
10391037
i_it->statement=="checkcast" ||
@@ -1048,7 +1046,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
10481046
i_it->statement=="invokestatic" ||
10491047
i_it->statement=="invokevirtual" ||
10501048
i_it->statement=="invokespecial" ||
1051-
i_it->statement=="invokeinterface")
1049+
i_it->statement=="invokeinterface" ||
1050+
(threading_support && (i_it->statement=="monitorenter" ||
1051+
i_it->statement=="monitorexit")))
10521052
{
10531053
const std::vector<unsigned int> handler =
10541054
try_catch_handler(i_it->address, method.exception_table);
@@ -1992,6 +1992,9 @@ codet java_bytecode_convert_methodt::convert_monitorenterexit(
19921992
"java::java.lang.Object.monitorenter:(Ljava/lang/Object;)V" :
19931993
"java::java.lang.Object.monitorexit:(Ljava/lang/Object;)V";
19941994

1995+
if(!threading_support || !symbol_table.has_symbol(descriptor))
1996+
return code_skipt();
1997+
19951998
// becomes a function call
19961999
code_typet type(
19972000
{code_typet::parametert(java_reference_type(void_typet()))},
@@ -3105,7 +3108,9 @@ void java_bytecode_convert_method(
31053108
bool throw_assertion_error,
31063109
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
31073110
java_string_library_preprocesst &string_preprocess,
3108-
const class_hierarchyt &class_hierarchy)
3111+
const class_hierarchyt &class_hierarchy,
3112+
bool threading_support)
3113+
31093114
{
31103115
if(std::regex_match(
31113116
id2string(class_symbol.name),
@@ -3124,7 +3129,8 @@ void java_bytecode_convert_method(
31243129
throw_assertion_error,
31253130
needed_lazy_methods,
31263131
string_preprocess,
3127-
class_hierarchy);
3132+
class_hierarchy,
3133+
threading_support);
31283134

31293135
java_bytecode_convert_method(class_symbol, method);
31303136
}

cbmc/jbmc/src/java_bytecode/java_bytecode_convert_method.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ void java_bytecode_convert_method(
3636
bool throw_assertion_error,
3737
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
3838
java_string_library_preprocesst &string_preprocess,
39-
const class_hierarchyt &class_hierarchy);
39+
const class_hierarchyt &class_hierarchy,
40+
bool threading_support);
4041

4142
void java_bytecode_convert_method_lazy(
4243
const symbolt &class_symbol,

cbmc/jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ class java_bytecode_convert_methodt:public messaget
3939
bool throw_assertion_error,
4040
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
4141
java_string_library_preprocesst &_string_preprocess,
42-
const class_hierarchyt &class_hierarchy)
42+
const class_hierarchyt &class_hierarchy,
43+
bool threading_support)
4344
: messaget(_message_handler),
4445
symbol_table(symbol_table),
4546
max_array_length(_max_array_length),
4647
throw_assertion_error(throw_assertion_error),
48+
threading_support(threading_support),
4749
needed_lazy_methods(std::move(needed_lazy_methods)),
4850
string_preprocess(_string_preprocess),
4951
slots_for_parameters(0),
@@ -67,6 +69,7 @@ class java_bytecode_convert_methodt:public messaget
6769
symbol_table_baset &symbol_table;
6870
const size_t max_array_length;
6971
const bool throw_assertion_error;
72+
const bool threading_support;
7073
optionalt<ci_lazy_methods_neededt> needed_lazy_methods;
7174

7275
/// Fully qualified name of the method under translation.

0 commit comments

Comments
 (0)