Skip to content

Commit d23ffc6

Browse files
committed
Concurrency: do not lose L2 entries of newly spawned threads
When spawning threads, procedure-local variables are copied into the newly spawned thread. Merging goto states in the spawning thread must not result in losing the L2 entries of those copies.
1 parent 53616ca commit d23ffc6

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
void foo(unsigned x)
2+
{
3+
__CPROVER_assert(x <= 1, "");
4+
}
5+
6+
int main()
7+
{
8+
unsigned local_to_main;
9+
local_to_main %= 2;
10+
_Bool nondet1;
11+
if(nondet1)
12+
{
13+
__CPROVER_ASYNC_1:
14+
foo(local_to_main);
15+
return 0;
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Procedure-local variables must be copied into a newly created thread, and must
11+
not be lost when merging goto states.

src/goto-symex/symex_goto.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,12 @@ static void merge_names(
775775
// only later be removed from level2.current_names by pop_frame
776776
// once the thread is executed)
777777
const irep_idt level_0 = ssa.get_level_0();
778-
if(!level_0.empty() && level_0 != std::to_string(dest_state.source.thread_nr))
778+
if(
779+
!level_0.empty() &&
780+
level_0 != std::to_string(dest_state.source.thread_nr) && dest_count != 0)
781+
{
779782
return;
783+
}
780784

781785
exprt goto_state_rhs = ssa, dest_state_rhs = ssa;
782786

0 commit comments

Comments
 (0)