Skip to content

Fail to mark variable as static lifetime #851

Open
@owen-mc-diffblue

Description

@owen-mc-diffblue

Steps to reproduce:

  1. Create a.java:
    class a { public static void fun() { assert(b.x > 5); } }
  2. Create b.java:
    public class b { static int x =5; }
  3. Compile a.java, which also compiles b.java:
    javac a.java
  4. Rename b.class:
    mv b.class b.class.bak
  5. Run cbmc on a.class with the flags --function a.fun --cover branch --show-goto-functions and observe that b.x is used without ever being initialised to a NONDET(int).
  6. Run cbmc on a.class with the flags --function a.fun --cover branch --show-symbol-table and observe that b.x is in the symbol table but not marked as is_static_lifetime.

I believe the problem is that typecheck_expr_symbol() in java_bytecode/java_bytecode_typecheck_expr.cpp isn't passed any information about whether the symbol is static, even if we know it's called with getstatic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Fail to mark variable as static lifetime · Issue #851 · diffblue/cbmc