Skip to content

Commit b934aaf

Browse files
committed
symex_dynamic::dynamic_object_size* are constants
We do not have a notion of guaranteed constants, thus mark them thread-local via the auxiliary_symbolt constructor. This avoids repeated renaming of the size of an array, which resulted in spurious errors in concurrent programs (e.g., in SV-COMP running "cbmc --unwind 2 --stop-on-fail --32 c/pthread-C-DAC/pthread-numerical-integration_true-unreach-call.i").
1 parent ef83f93 commit b934aaf

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdlib.h>
2+
#include <pthread.h>
3+
4+
_Bool set_done;
5+
int *ptr;
6+
7+
void *set_x(void *arg)
8+
{
9+
*(int *)arg = 10;
10+
set_done = 1;
11+
}
12+
13+
int main(int argc, char *argv[])
14+
{
15+
__CPROVER_assume(argc >= sizeof(int));
16+
ptr = malloc(argc);
17+
__CPROVER_ASYNC_1: set_x(ptr);
18+
__CPROVER_assume(set_done);
19+
assert(*ptr == 10);
20+
return 0;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/goto-symex/symex_builtin_functions.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,15 @@ void goto_symext::symex_allocate(
138138
{
139139
exprt &size=to_array_type(object_type).size();
140140

141-
symbolt size_symbol;
141+
auxiliary_symbolt size_symbol;
142142

143143
size_symbol.base_name=
144144
"dynamic_object_size"+std::to_string(dynamic_counter);
145145
size_symbol.name="symex_dynamic::"+id2string(size_symbol.base_name);
146-
size_symbol.is_lvalue=true;
147146
size_symbol.type=tmp_size.type();
148147
size_symbol.mode = mode;
148+
size_symbol.type.set(ID_C_constant, true);
149+
size_symbol.value = size;
149150

150151
state.symbol_table.add(size_symbol);
151152

0 commit comments

Comments
 (0)