Skip to content

identifier __CPROVER_memory not found #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
peterschrammel opened this issue Aug 10, 2016 · 9 comments
Closed

identifier __CPROVER_memory not found #197

peterschrammel opened this issue Aug 10, 2016 · 9 comments
Assignees
Labels

Comments

@peterschrammel
Copy link
Member

peterschrammel commented Aug 10, 2016

Hello,

current CBMC master crashes on the attached Java program (distilled
from production code).

Thanks,

Vladimir Klebanov


CBMC version 5.4 64-bit x86_64 linux
Parsing Driver.class
Java main class: Driver
failed to load class java.lang.String' failed to load classjava.lang.Object'
failed to load class java.lang.Class' failed to load classjava.lang.AssertionError'
Converting
Generating GOTO Program
Adding CPROVER library (x86_64)
Removal of function pointers and virtual functions
Partial Inlining
Generic Property Instrumentation
Starting Bounded Model Checking
**** WARNING: no body for function
java::java.lang.Class.desiredAssertionStatus:()Z
**** WARNING: no body for function java::java.lang.Object.:()V
**** WARNING: no body for function java::java.lang.AssertionError.:()V
file Driver.java line 50: identifier __CPROVER_memory not found

public class Driver {

    static byte[] out,in;

    public static void main(String[] argv) {

        X x = new X();
        x.y(out);

    }

}

final class X {

    private static final int DIGEST_SIZE = 20;
    private transient MyMessageDigest digest;
    private byte[] state;

    public X() {
        init(null);
    }

    private void init(byte[] seed) {
        digest = new MyMessageDigest();

        if (seed != null) {
            state = digest.digest(seed);
        }
    }

    public synchronized void y(byte[] result) {
        byte[] output = digest.digest();
    }
}


class MyMessageDigest {

    private byte[] state = null;


    public void update(byte[] input) {
        assert(input.length == 20);
        state = input;
    }


    public byte[] digest() {
        byte[] tmp = state;
        state = null;
        return tmp;
    }

    public byte[] digest(byte[] input) {
        update(input);
        return digest();
    }


}
@vladrich
Copy link
Contributor

Thanks. I now see that this is a duplicate of #161. Sorry about that.

@peterschrammel
Copy link
Member Author

We have a patch that fixes the problem in one of our branches. We'll distil a PR for it asap.

@smowton
Copy link
Contributor

smowton commented Aug 17, 2016

Looks like the principle cause is implicit pointer casting between void* and struct Driver* introducing a byte-extract operation and thus pointer-analysis uncertainty and the possibility that the pointer is an integer address (i.e. something like *(char*)5, which is obviously not possible in Java). I have a patch in my branch that tries to make all pointer casts explicit which I'll try to extract tomorrow.

@smowton
Copy link
Contributor

smowton commented Aug 18, 2016

smowton@5787def fixes this particular case by ensuring all pointer-casting is explicit, and so bytewise reinterpret opcodes are not generated. There may however be other cases where the value set analysis conflates integer and pointer members of the same struct which would lead to the same problem recurring; if that happens we should consider making the pass aware that the source language can't express raw integer addresses, and so in this case anything that would use __CPROVER_memory can be silently discarded.

@vladrich
Copy link
Contributor

Thanks for looking at this, Chris. I grafted your patch onto current master and it does prevent the crash. Verification of the particular benchmark now completes, but the results are surprising to me. At the moment, I cannot say if this is a genuine finding or some misunderstanding of mine. I will investigate the issue.

@vladrich
Copy link
Contributor

The problem no longer occurs with current master (518124c). Thanks.

@smowton
Copy link
Contributor

smowton commented Aug 31, 2016

Per https://github.com/diffblue/verification-engine-utils/issues/173 there are more cases where this can happen; therefore __CPROVER_memory refs are disabled entirely in smowton@733b753

@smowton
Copy link
Contributor

smowton commented Sep 8, 2016

(Just a note this should be review/QA but I don't have the right to do that on the CBMC tracker)

@smowton
Copy link
Contributor

smowton commented Dec 5, 2016

Created #335 to try to get this either integrated or commented upon.

kroening pushed a commit that referenced this issue Feb 8, 2017
goto-symex's value-set analysis can reach the conclusion that an integer may be cast
to a pointer, and so generate a reference to the __CPROVER_memory symbol. This is
invalid in Java however, since the symbol is not defined and of course Java cannot
express dereferencing a non-pointer type.

This change disables generation of __CPROVER_memory references when a Java-typed
entry point is found. I couldn't provide a test case against master at this time however
because the examples in both of the above bugs now succeed against master, presumably
because value-set analysis has been improved and is harder to confuse into introducing
a pointer-to-int cast.
smowton pushed a commit to smowton/cbmc that referenced this issue May 9, 2018
…inal_in_HTML_dump

SEC-66 : Added ordinals of instructions in GOTO functions in HTML dump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants