Skip to content

Commit 1abd8a7

Browse files
Prefix identifiers in stubs with function name
The name of an auxiliary variable must not depend on other functions in the symbol table.
1 parent da34ceb commit 1abd8a7

File tree

8 files changed

+79
-9
lines changed

8 files changed

+79
-9
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Opaque extends Exception
2+
{
3+
public static Opaque static_field;
4+
public Opaque field;
5+
6+
public Opaque(Opaque o) {
7+
}
8+
9+
public static Opaque static_method(Opaque o) {
10+
return o;
11+
}
12+
13+
public Opaque[] method(Opaque[] o) {
14+
return o;
15+
}
16+
}
635 Bytes
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class Test
2+
{
3+
public static void f00(Opaque z)
4+
{
5+
try {
6+
Opaque x = new Opaque(Opaque.static_field);
7+
Opaque[] a = {Opaque.static_method(x.field), z};
8+
Opaque[] y = x.method(a);
9+
throw y[0];
10+
}
11+
catch(Opaque o) {
12+
}
13+
}
14+
public Opaque f01(Opaque z)
15+
{
16+
try {
17+
Opaque x = new Opaque(Opaque.static_field);
18+
Opaque[] a = {Opaque.static_method(x.field), z};
19+
Opaque[] y = x.method(a);
20+
throw y[0];
21+
}
22+
catch(Opaque o) {
23+
return o;
24+
}
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--show-symbol-table
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^Symbol\.*: malloc_site
8+
^Symbol\.*: to_construct
9+
^Symbol\.*: to_return
10+
^Symbol\.*: this
11+
^Symbol\.*: caught_exception
12+
^Symbol\.*: anonlocal
13+
^Symbol\.*: stub_ignored_arg
14+
^Symbol\.*: #return_value
15+
^Symbol\.*: return_tmp
16+
^Symbol\.*: new_tmp
17+
^Symbol\.*: tmp_new_data_array
18+
^Symbol\.*: newarray_tmp

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ static void java_static_lifetime_init(
117117
symbol_table_baset &symbol_table,
118118
const source_locationt &source_location,
119119
bool assume_init_pointers_not_null,
120-
const object_factory_parameterst &object_factory_parameters,
120+
object_factory_parameterst object_factory_parameters,
121121
const select_pointer_typet &pointer_type_selector,
122122
bool string_refinement_enabled)
123123
{
124124
symbolt &initialize_symbol=*symbol_table.get_writeable(INITIALIZE_FUNCTION);
125125
code_blockt &code_block=to_code_block(to_code(initialize_symbol.value));
126-
126+
object_factory_parameters.function_id = initialize_symbol.name;
127+
127128
// We need to zero out all static variables, or nondet-initialize if they're
128129
// external. Iterate over a copy of the symtab, as its iterators are
129130
// invalidated by object_factory:

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ exprt object_factory(
14891489
code_blockt &init_code,
14901490
bool allow_null,
14911491
symbol_table_baset &symbol_table,
1492-
const object_factory_parameterst &parameters,
1492+
object_factory_parameterst parameters,
14931493
allocation_typet alloc_type,
14941494
const source_locationt &loc,
14951495
const select_pointer_typet &pointer_type_selector)
@@ -1504,7 +1504,8 @@ exprt object_factory(
15041504
main_symbol.base_name=base_name;
15051505
main_symbol.type=type;
15061506
main_symbol.location=loc;
1507-
1507+
parameters.function_id = identifier;
1508+
15081509
exprt object=main_symbol.symbol_expr();
15091510

15101511
symbolt *main_symbol_ptr;

jbmc/src/java_bytecode/java_object_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exprt object_factory(
9292
code_blockt &init_code,
9393
bool allow_null,
9494
symbol_table_baset &symbol_table,
95-
const object_factory_parameterst &parameters,
95+
object_factory_parameterst parameters,
9696
allocation_typet alloc_type,
9797
const source_locationt &location,
9898
const select_pointer_typet &pointer_type_selector);

jbmc/src/java_bytecode/simple_method_stubbing.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class java_simple_method_stubst
3939
const typet &expected_type,
4040
const exprt &ptr,
4141
const source_locationt &loc,
42+
const irep_idt &function_id,
4243
code_blockt &parent_block,
4344
unsigned insert_before_index,
4445
bool is_constructor,
@@ -77,6 +78,7 @@ void java_simple_method_stubst::create_method_stub_at(
7778
const typet &expected_type,
7879
const exprt &ptr,
7980
const source_locationt &loc,
81+
const irep_idt &function_id,
8082
code_blockt &parent_block,
8183
const unsigned insert_before_index,
8284
const bool is_constructor,
@@ -108,6 +110,8 @@ void java_simple_method_stubst::create_method_stub_at(
108110

109111
// Generate new instructions.
110112
code_blockt new_instructions;
113+
object_factory_parameterst parameters = object_factory_parameters;
114+
parameters.function_id = function_id;
111115
gen_nondet_init(
112116
to_init,
113117
new_instructions,
@@ -116,7 +120,7 @@ void java_simple_method_stubst::create_method_stub_at(
116120
is_constructor,
117121
allocation_typet::DYNAMIC,
118122
!assume_non_null,
119-
object_factory_parameters,
123+
parameters,
120124
update_in_place ? update_in_placet::MUST_UPDATE_IN_PLACE
121125
: update_in_placet::NO_UPDATE_IN_PLACE);
122126

@@ -155,7 +159,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
155159
const typet &this_type = this_argument.type();
156160
symbolt &init_symbol = get_fresh_aux_symbol(
157161
this_type,
158-
"to_construct",
162+
id2string(symbol.name),
159163
"to_construct",
160164
synthesized_source_location,
161165
ID_java,
@@ -169,6 +173,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
169173
this_type,
170174
init_symbol_expression,
171175
synthesized_source_location,
176+
symbol.name,
172177
new_instructions,
173178
1,
174179
true,
@@ -181,14 +186,16 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
181186
{
182187
symbolt &to_return_symbol = get_fresh_aux_symbol(
183188
required_return_type,
184-
"to_return",
189+
id2string(symbol.name),
185190
"to_return",
186191
synthesized_source_location,
187192
ID_java,
188193
symbol_table);
189194
const exprt &to_return = to_return_symbol.symbol_expr();
190195
if(to_return_symbol.type.id() != ID_pointer)
191196
{
197+
object_factory_parameterst parameters = object_factory_parameters;
198+
parameters.function_id = symbol.name;
192199
gen_nondet_init(
193200
to_return,
194201
new_instructions,
@@ -197,14 +204,15 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
197204
false,
198205
allocation_typet::LOCAL, // Irrelevant as type is primitive
199206
!assume_non_null,
200-
object_factory_parameters,
207+
parameters,
201208
update_in_placet::NO_UPDATE_IN_PLACE);
202209
}
203210
else
204211
create_method_stub_at(
205212
required_return_type,
206213
to_return,
207214
synthesized_source_location,
215+
symbol.name,
208216
new_instructions,
209217
0,
210218
false,

0 commit comments

Comments
 (0)