Skip to content

Commit 174d261

Browse files
committed
Squashed 'cbmc/' changes from 7c1de91..6fd77f4
6fd77f4 Merge pull request diffblue#2472 from smowton/smowton/fix/nondet-stringbuilders 5423ea4 Merge pull request diffblue#2488 from polgreen/common_call_graph_funcs a2a5662 Merge pull request diffblue#2263 from JohnDumbell/bugfix/nondet_direct_return bbf0d02 Merge pull request diffblue#2482 from antlechner/antonia/direct-children-of-class c982c21 Merge pull request diffblue#2486 from Degiorgio/jbmc-synchronoization-asymmetry-fix 8e7b6e7 Java object factory: initialize AbstractStringBuilder-derived types correctly 9af7ef1 Add tests for new class_hierarchy_grapht functions 79cad15 Fix existing class hierarchy test syntax dbac316 Add documentation to class_hierarchyt 3ecac30 Move non-graph function below graph functions 4badd8f Add useful functions to class_hierarchy_grapht 610467e Merge pull request diffblue#2480 from smowton/smowton/admin/graph-unit-tests 2431ac0 Doxygen formatting for dependence_graph test includes 19a1ceb factor out common call graph unit test functions into header deff59d Add tests for grapht::make_chordal and grapht::connected_subgraphs e94208f Merge pull request diffblue#2428 from tautschnig/vs-ref d00d833 Fix: several grapht functions were uncompilable if ever called b9014de Merge pull request diffblue#2381 from polgreen/depth_limited_search 7c767ab Merge pull request diffblue#2485 from tautschnig/vs-unreachable da76500 JBMC: Fixed asymmetry between synchronized blocks and methods. 5918640 Merge pull request diffblue#2487 from JohnDumbell/bugfix/add_java_load_class d65c655 Merge pull request diffblue#2484 from tautschnig/vs-printf 91e8b89 Fix for nondet replacement on a direct return (pre-remove returns) 904132d unit tests for depth limited search on call graph 2c76d0d call graph helper interface to depth limited search 64fdb9b depht limited search for grapht e708bfb Adds --java-load-class to tests that require it 6665c69 Remove unreachable instructions 6e4d5a7 printf does not and should not have a left-hand side 2111f7c Merge pull request diffblue#2475 from tautschnig/vs-wmm 6566d10 Merge pull request diffblue#2469 from tautschnig/vs-string2 3703974 Merge pull request diffblue#2477 from tautschnig/vs-string-abstraction cf797da Merge pull request diffblue#2473 from tautschnig/vs-update c07a09b Merge pull request diffblue#2476 from tautschnig/vs-cex e504e80 Remove unused parameter in string abstraction 4d88b98 Remove unused parameter in counterexample beautification 888f168 Remove unused parameter from update_scores 461754d Remove unused parameters in goto-instrument/wmm 93300aa Use string2unsigned when reading/expecting an unsigned 1a7033a String refinement: Take a reference to avoid copy git-subtree-dir: cbmc git-subtree-split: 6fd77f4
1 parent 04b23a8 commit 174d261

File tree

104 files changed

+1437
-470
lines changed

Some content is hidden

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

104 files changed

+1437
-470
lines changed

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$

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

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.

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.

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
--

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$

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+
}
Binary file not shown.
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)

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

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

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+
}
Binary file not shown.
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+
}
Binary file not shown.
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+
}
Binary file not shown.
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

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

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

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$

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,6 @@ codet java_bytecode_convert_methodt::convert_instructions(
10261026
}
10271027

10281028
if(i_it->statement=="athrow" ||
1029-
i_it->statement=="monitorenter" ||
1030-
i_it->statement=="monitorexit" ||
10311029
i_it->statement=="putfield" ||
10321030
i_it->statement=="getfield" ||
10331031
i_it->statement=="checkcast" ||
@@ -1042,7 +1040,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
10421040
i_it->statement=="invokestatic" ||
10431041
i_it->statement=="invokevirtual" ||
10441042
i_it->statement=="invokespecial" ||
1045-
i_it->statement=="invokeinterface")
1043+
i_it->statement=="invokeinterface" ||
1044+
(threading_support && (i_it->statement=="monitorenter" ||
1045+
i_it->statement=="monitorexit")))
10461046
{
10471047
const std::vector<unsigned int> handler =
10481048
try_catch_handler(i_it->address, method.exception_table);
@@ -1986,6 +1986,9 @@ codet java_bytecode_convert_methodt::convert_monitorenterexit(
19861986
"java::java.lang.Object.monitorenter:(Ljava/lang/Object;)V" :
19871987
"java::java.lang.Object.monitorexit:(Ljava/lang/Object;)V";
19881988

1989+
if(!threading_support || !symbol_table.has_symbol(descriptor))
1990+
return code_skipt();
1991+
19891992
// becomes a function call
19901993
code_typet type(
19911994
{code_typet::parametert(java_reference_type(void_typet()))},
@@ -3099,7 +3102,9 @@ void java_bytecode_convert_method(
30993102
bool throw_assertion_error,
31003103
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
31013104
java_string_library_preprocesst &string_preprocess,
3102-
const class_hierarchyt &class_hierarchy)
3105+
const class_hierarchyt &class_hierarchy,
3106+
bool threading_support)
3107+
31033108
{
31043109
if(std::regex_match(
31053110
id2string(class_symbol.name),
@@ -3118,7 +3123,8 @@ void java_bytecode_convert_method(
31183123
throw_assertion_error,
31193124
needed_lazy_methods,
31203125
string_preprocess,
3121-
class_hierarchy);
3126+
class_hierarchy,
3127+
threading_support);
31223128

31233129
java_bytecode_convert_method(class_symbol, method);
31243130
}

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,

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)