Giter VIP home page Giter VIP logo

jvm-verifier's Introduction

This repository contains the code for the Java Symbolic Simulator (JSS). It is currently used primarily as a library from SAWScript, but also produces a stand-alone executable, jss.

For information on using jss, see the tutorial in doc/japi-tutorial.

jvm-verifier's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jvm-verifier's Issues

Can't handle 'switch' statements with more than one 'case'.

It appears that JSS can't handle switch statements with more than one case. I ran into this when I tried to add a new Java example to the tutorial in doc/tutorial/code/FFS.java in the saw-script repo and it made SAW crash:

static int ffs_imp2(int i) {
    switch (((~i) + 1) ^ i) {
    case 0b11111111111111111111111111111110: return 1;
    case 0b11111111111111111111111111111100: return 2;
    case 0b11111111111111111111111111111000: return 3;
    case 0b11111111111111111111111111110000: return 4;
    case 0b11111111111111111111111111100000: return 5;
    case 0b11111111111111111111111111000000: return 6;
    case 0b11111111111111111111111110000000: return 7;
    case 0b11111111111111111111111100000000: return 8;
    case 0b11111111111111111111111000000000: return 9;
    case 0b11111111111111111111110000000000: return 10;
    case 0b11111111111111111111100000000000: return 11;
    case 0b11111111111111111111000000000000: return 12;
    case 0b11111111111111111110000000000000: return 13;
    case 0b11111111111111111100000000000000: return 14;
    case 0b11111111111111111000000000000000: return 15;
    case 0b11111111111111110000000000000000: return 16;
    case 0b11111111111111100000000000000000: return 17;
    case 0b11111111111111000000000000000000: return 18;
    case 0b11111111111110000000000000000000: return 19;
    case 0b11111111111100000000000000000000: return 20;
    case 0b11111111111000000000000000000000: return 21;
    case 0b11111111110000000000000000000000: return 22;
    case 0b11111111100000000000000000000000: return 23;
    case 0b11111111000000000000000000000000: return 24;
    case 0b11111110000000000000000000000000: return 25;
    case 0b11111100000000000000000000000000: return 26;
    case 0b11111000000000000000000000000000: return 27;
    case 0b11110000000000000000000000000000: return 28;
    case 0b11100000000000000000000000000000: return 29;
    case 0b11000000000000000000000000000000: return 30;
    case 0b10000000000000000000000000000000: return 31;
    case 0b00000000000000000000000000000000: return i == 0 ? 0 : 32;
    }
    return 0; // Unreachable.
}

Here are simple crashing and non-crashing examples:

// Crash.
static int ffs_imp3_4(int i) {
    switch (i) {
    case 0: break;
    case 1: break;
    }
    return 0;
}

// No crash, compare bytecode with ffs_imp3_4.
static int ffs_imp3(int i) {
    switch (i) {
    case 0: break;
    }
    return 0;
}

And here is the corresponding Java bytecode -- extracted with javap -c FFS -- which is what JSS is actually processing. Crash:

static int ffs_imp3_4(int);
  Code:
     0: iload_0
     1: lookupswitch  { // 2
                   0: 28
                   1: 31
             default: 31
        }
    28: goto          31
    31: iconst_0
    32: ireturn

No crash:

static int ffs_imp3(int);
  Code:
     0: iload_0
     1: lookupswitch  { // 1
                   0: 20
             default: 20
        }
    20: iconst_0
    21: ireturn

The lookupswitch JVM bytecode is processed by switch in src/Data/JVM/Symbolic/Translation.hs, and the problem manifests as an empty stack pop in popValue in src/Verifier/Java/Simulator.hs.

I pushed a debug-broken-java-switch-statements branch with these examples and some printf debugging inserted; I got side tracked failing to build SAW with profiling support to get stack traces. Run saw ffs_java.saw to see the crash.

Support `Arrays.copyOf`

The native Arrays.copyOf method in Java isn't currently supported by JSS, and as a native method can't be symbolically executed. We should add an override for it.

Load .class files lazily.

JSS currently loads all .class files it can find below the current dir on start up. This can be very slow. Instead, we should load the .class files lazily as needed. Some relevant code in src/Verifier/Java/Codebase.hs was updated in 0b0514f.

Support Java 8 .class files

We originally developed the JVM .class file parser with Java 6, and haven't extended it in a while. It can load some files generated from later versions, but not all. We should extend it to support all Java 8 constructs.

AIG generation depends on backend

Using the word backend results in different AIG output than the SAW backend. This is related, I believe, to different assumptions regarding bit-order; the word backend operates least-significant-bit-first, but the SAW backend conforms to the Cryptol 2 semantics, which is most-significant-bit-first.

There may be other related issues where bit-ordering assumptions affect the results; these should also be teased out.

Support `System.arrayCopy`

The native System.arrayCopy method in Java isn't currently supported by JSS, and as a native method can't be symbolically executed. We should add an override for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.