Skip to content

Wrong report of assertion failure for access to shared memory through global pointer #305

Open
@danpoe

Description

@danpoe

In the following example, cbmc reports an assertion failure for assert(*v == 1). It is however able to correctly deduce v == &g in the other two assertions.

#include <pthread.h>
#include <assert.h>

int *v;
int g;

void *thread1(void * arg)
{
  v = &g;
}

void *thread2(void *arg)
{
  assert(v == &g);
  *v = 1;
}

int main()
{
  pthread_t t1, t2;

  pthread_create(&t1, 0, thread1, 0);
  pthread_join(t1, 0);

  pthread_create(&t2, 0, thread2, 0);
  pthread_join(t2, 0);

  assert(v == &g);
  assert(*v == 1);

  return 0;
}

This is regression test regression/cbmc/concurrency/global_pointer1 in #303 .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions