[Soot-list] Soot/Spark GC overhead limit exceeded and the Android Framework

Jason Ott jott002 at ucr.edu
Thu Apr 2 14:15:21 EDT 2015


So I'm trying to run soot with spark on the Android Framework using a
custom entry point.

Here is my the code that runs soot:

    public class Main {
        public static void main(String[] args) {

            String entryPointClass = args[args.length-2];
            String entryPointMethod = args[args.length-1];

            System.out.println(entryPointClass + "." + entryPointMethod);

            args = Arrays.copyOf(args, args.length-2);

            long start = System.currentTimeMillis();
            Options.v().parse(args);
            SootClass c = Scene.v().forceResolve(entryPointClass,
SootClass.BODIES);
            c.setApplicationClass();
            Scene.v().loadNecessaryClasses();
            SootMethod method = c.getMethodByName(entryPointMethod);
            List entryPoints = new ArrayList();
            entryPoints.add(method);
            Scene.v().setEntryPoints(entryPoints);
            PackManager.v().runPacks();

            soot.jimple.toolkits.callgraph.CallGraph callgraph =
Scene.v().getCallGraph();
            System.out.println("[TestSpark] Call graph size " +
callgraph.size());

            System.out.println(String.format("It took: %d seconds to
generate a callgraph for: %s",

TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start),
                    entryPointClass +"."+ entryPointMethod));
            }
}

I would run this as follows:
java -Xmx:1024mb -jar mySpark.jar -p cg.spark on -process-dir
/Users/jason/Desktop/android/pscout/android_source_dir/ -cp
/Users/jason/Desktop/android/pscout/android_source_dir:.
-allow-phantom-refs android.content.ClipboardManager hasText

The last two args end up being the api class and the api method that I want
to start the graph at.

When I run this jar I get a "java.lang.OutOfMemoryError: GC overhead limit
exceeded" error.  I've given the JVM as mucha s 8gb and it still exhausts
memory.

Now I must admit that to even get this to work I had to tweak the Soot
source code a bit.  I had to alter the following:

   - Line 99 in soot/src//soot/asm/SootClassBuilder.java will not throw an
   exception with my code.  The line now prints an error and moves on.  As I
   was reading the code and reading other examples, this is tolerable because
   Soot still finds the methods in those classes (presumably, as it doesn't
   throw any errors about not finding methods)

Can soot handle the entire android framework?
Is my method and approach proper?
Are there any indications as to why I'm running into a GC Memory error and
how to fix it?
Is my change to soot source code the root of this problem?

Thank you for any assistance you may provide.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150402/fabce66b/attachment.html 


More information about the Soot-list mailing list