Skip to content

Java frontend needs to be lazier converting methods #284

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
smowton opened this issue Oct 31, 2016 · 4 comments
Closed

Java frontend needs to be lazier converting methods #284

smowton opened this issue Oct 31, 2016 · 4 comments

Comments

@smowton
Copy link
Contributor

smowton commented Oct 31, 2016

At present the Java frontend walks the classpath looking for any type reference and converting any method defined on such a type. When the standard library JAR is available this results in far too much getting loaded, due to obscure references that most programs don't use-- for example, loading all of java.lang.System due to some trivial reference in a deserialization routine. To improve on this I am currently working on a simple lazy loading scheme, where all methods are initially stubbed, and then each is converted only when we find a call that may reach it (including through virtual dispatch). For example the following program currently runs out of memory when the standard library is available to parse:

import java.util.ArrayList;

public class al {

  public static void main(int args) {

    ArrayList<Integer> a = new ArrayList<Integer>();
    a.add(args);
    int i = a.get(0);

  }

}

With these changes the dependencies for simple construct, add and get should hopefully be much smaller.

Note that the types are still loaded eagerly, for simplicity-- only method bodies are populated on demand.

@kroening
Copy link
Member

kroening commented Nov 1, 2016

Yes, indeed! Please keep me up-to-date.

@smowton
Copy link
Contributor Author

smowton commented Nov 1, 2016

cristina-david@04a0ca5 and cristina-david@a9fe0bf provide a rough sketch of what we could do without much effort. They shrink the memory requirement for the basic program above to 1.2GB, which is of course still not good, but at least it's loadable (in around 2 seconds). I'll put pull request against master together once I'm happy it's reliable.

It still can't be fed into CBMC however because it does lots of unwinding and unrolling down paths that build exception error messages in the standard library. They could perhaps be blacklisted to make including rt.jar more practical.

@smowton
Copy link
Contributor Author

smowton commented Nov 3, 2016

This is extended a little further in my branch november_sprint_based_on_test_gen to restrict virtual function dispatch to only those types that are either parameters to, or are created within, the functions reachable from the analysis entry point.

@smowton
Copy link
Contributor Author

smowton commented Mar 23, 2017

Committed to master in #407

@smowton smowton closed this as completed Mar 23, 2017
smowton pushed a commit to smowton/cbmc that referenced this issue May 9, 2018
…erate_empty_jar

SEC-142: Bugfix: prevent generation of empty JAR (when no class files are found).
chrisr-diffblue added a commit to chrisr-diffblue/cbmc that referenced this issue Aug 24, 2018
…rry-pick

FP constant folding fix cherry pick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants