sireum / archived-v2-amandroid

34 stars 16 forks source link

NullPointerException when analyzing APK #24

Closed eugenood closed 9 years ago

eugenood commented 9 years ago

Hi. Whenever I run sireum amandroid genCallGraph, I got NullPointerException output in the .errorlog file. The error log is similar to that of issue #17:

An error occured on 20150325-145830
java.lang.NullPointerException
    at scala.collection.mutable.ArrayOps$ofRef$.length$extension(ArrayOps.scala:192)
    at scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:192)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:32)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
    at org.sireum.util.FileUtil$.listFiles(File.scala:51)
    at org.sireum.jawa.JawaCodeSource$.load(JawaCodeSource.scala:75)
    at org.sireum.amandroid.cli.GenCallGraph$$anonfun$genCallGraph$1.apply(GenCallGraph.scala:137)
    at org.sireum.amandroid.cli.GenCallGraph$$anonfun$genCallGraph$1.apply(GenCallGraph.scala:123)
    at scala.collection.immutable.Set$Set1.foreach(Set.scala:79)
    at org.sireum.amandroid.cli.GenCallGraph$.genCallGraph(GenCallGraph.scala:122)
    at org.sireum.amandroid.cli.GenCallGraph$.main(GenCallGraph.scala:112)
    at org.sireum.amandroid.cli.GenCallGraph.main(GenCallGraph.scala)

Similar to that issue, I was able to run on Ubuntu 14.04, but unable to run on CentOS 6.5. The suggested solution is to install lib32, but which package, in particular, do I need?

Additional information: I did not compile it via Eclipse, but instead used the built version from sireum site, and run sireum amandroid to install the necessary files. Also, the system doesn't have a lib32 directory, only lib and lib64.

fgwei commented 9 years ago

You can go to Sireum/apps/amandroid/dex2pilar/linux64 and then 'ldd newdex2pilar' it should list the missing libraries. For install lib32 you can try: http://sixarm.com/about/ubuntu-apt-get-install-ia32-for-32-bit-on-64-bit.html

eugenood commented 9 years ago

Found the dependencies. Solved and thanks.

eugenood commented 9 years ago

I realized that on the development branch, there is a particular dependency named libc++.so. In particular, when I ldd newdex2pillar, this is what I got.

    linux-gate.so.1 =>  (0xf77bf000)
    libc++.so => not found
    libpthread.so.0 => /lib32/libpthread.so.0 (0xf7764000)
    libz.so.1 => /usr/lib32/libz.so.1 (0xf774a000)
    libc.so.6 => /lib32/libc.so.6 (0xf759f000)
    libm.so.6 => /lib32/libm.so.6 (0xf7559000)
    /lib/ld-linux.so.2 (0xf77c0000)

At first, I thought this is the libcxx library, so I tried compiling them, but the libc++.so is still not found. What should I do to obtain this particular library?

fgwei commented 9 years ago

You can try this one apt-get install lib32stdc++6.

eugenood commented 9 years ago

Sorry, does not work. Here is more information that might be useful. Before I switched to development branch (i.e. I'm in stable branch), the newdex2pilar does not require such dependency. But after I switched and update, this dependency is required. Right now, I could make it work by replacing the development version of newdex2pilar to the stable one. Even though I don't see any problem right now, do you think it will cause any?

fgwei commented 9 years ago

I remember the newdex2pilar in stable sireum cannot work on new android apps like > android5.0. And it cannot handle apps generated via intellij. Can you try this: sudo apt-get install libc6:i386 libstdc++6:i386 zlib1g:i386

eugenood commented 9 years ago

Still not working. Do you need any other information?

fgwei commented 9 years ago

I guess the libc++.so should already installed somewhere, but does not in your PATH.

eugenood commented 9 years ago

I found the libc++.so under /usr/lib, and added it both to PATH and LD_LIBRARY_PATH, exporting them, but it does not work.

fgwei commented 9 years ago

How ldd newdex2pilar shows?

eugenood commented 9 years ago

The same as before. In fact, I already added them before I asked the question.

eugenood commented 9 years ago

I manage to get it to work. Turns out, it requires the 32-bit version, when I have the 64-bit version. So, just apt-get install libc++-dev:i386 will do. However, when I tried to stage the Whatsapp app, it seems like it does not generate the graphs, is that an expected behavior, if so, why?

fgwei commented 9 years ago

Thanks for the information.

Have you updated sireum?

eugenood commented 9 years ago

Yes, just updated. Here is the output:

mainuser@thinkpad-ubuntu:~/Files$ sireum amandroid staging com.whatsapp.apk 
Total apks: 1
Cleaning up unclosed ZipFile for archive /home/mainuser/apktool/framework/1.apk
Cleaning up unclosed ZipFile for archive /home/mainuser/Files/com.whatsapp.apk

I can get the graphs by running on Sources provided with Amandroid, but not with these apps.

eugenood commented 9 years ago

I also got this when trying to use genGraph:

mainuser@thinkpad-ubuntu:~/Files$ sireum amandroid genGraph -t APK com.whatsapp.apk 
Unexpected type: APK
fgwei commented 9 years ago

Your last question was a bug in my code. Fixed in: https://github.com/sireum/amandroid/commit/e804be57d4910abbb9acca42201398598a67c197

eugenood commented 9 years ago

Noted. Thanks.

vitaliiavdiienko commented 9 years ago

The same error as in the 1st post appears in the DEV branch on my MAC.

The thing is that everything works on STABLE branch, but on DEV branch everything crashes.

I have tried via Eclipse and via ./sireum amandroid taintAnalysis.

Any idea how to fix this?

Thanks.

fgwei commented 9 years ago

Is the error still there?

vitaliiavdiienko commented 9 years ago

I have redownloaded Sireum and Amandroid and problem has been disappeared.