Preparation for the IFDS Exercise

Moderator: Applied Static Analysis

jlerch
Moderator
Moderator
Beiträge: 148
Registriert: 18. Okt 2005 14:45

Preparation for the IFDS Exercise

Beitrag von jlerch » 19. Mai 2016 10:57

In the lecture on the 2nd of June i will give you an introduction to the IFDS framework. In the second half of that lecture i want you to write an analysis using IFDS. This requires a set-up that will take a few minutes. Therefore, i kindly ask you to do that set-up in advance, such that we can immediately start programming during the lecture and have enough time to get to the interesting parts of the analysis.

The set-up requires to perform the following steps (description below):

git clone https://bitbucket.org/delors/opal.git
git clone https://github.com/Sable/heros.git
git clone https://github.com/stg-tud/apsa.git
cd opal
git checkout develop
sbt publishLocal
cd ../heros
cp ant.settings.template ant.settings
mkdir javadoc
ant publish-Local
cd ../apsa/2016/ifds/ifds-exercise
sbt eclipse
Import projects IFDS-exercise and IFDS-testcases in Eclipse
Verify set-up: should compile without errors, some tests should succeed


You probably already cloned the repositories OPAL and APSA and can skip these steps. However, note that the exercise requires branch develop of OPAL. Heros is an open-source implementation of the IFDS framework. The code for the exercise is located in apsa/2016/ifds and contains two projects. The "testcases" project is a simple Java project. The other contains a template for the analysis and is a Scala project that can be prepared as Eclipse project via "sbt eclipse". For this step to succeed, you need to first deploy OPAL and Heros to your local ivy repository. For OPAL this is done via "sbt publishLocal" and for Heros via "ant publish-Local". If you do not have ant installed you can also use Eclipse for this step: Import Heros as project into Eclipse. Then select the build.xml file and choose Run As -> Ant Build... from the context menu. Check the target "publish-Local" in the "Run Configuration" dialog. Note that the Heros build requires you to first copy the ant.settings.template file to ant.settings and to create a directory named "javadoc".

After you have performed all the steps make sure the set-up works. Import both projects located in apsa/2016/ifds into Eclipse. Both should compile without errors and you should be able to run the ScalaTests located in the ifds-Exercise project. Some tests will already be successful, but most will fail. Getting those failing tests to succeed will be part of the exercise.

Boddlnagg
Mausschubser
Mausschubser
Beiträge: 54
Registriert: 10. Dez 2012 12:07

Re: Preparation for the IFDS Exercise

Beitrag von Boddlnagg » 24. Mai 2016 19:23

I ran into some issues, and the following corrections/clarifications might be helpful for others:
- I needed to do sbt clean for the OPAL project after I had checked out the develop branch in order to have it successfully compile.
- It should be ant publish-local, not ant publish-Local
- For the eclipse import, you should select the import type "Existing Projects into Workspace" and then use <your-path>/apsa/2016/ifds as the root directory (this might be obvious for someone who works with Eclipse more regularly, but I usually only work with sbt and IntelliJ)
- You need to have Scala IDE with Scalatest support installed in Eclipse (https://marketplace.eclipse.org/content/scala-ide)
- The source files are encoded in UTF-8, so you have to set "Text file encoding" in the project properties accordingly.

With this, when I run idfs-exercise/src/test/scala/AnalysisTests.scala as ScalaTest, I get
Tests: succeeded 13, failed 26, canceled 0, ignored 0, pending 0
... which seems to be correct/expected. The other project also shows no error, so seems to compile.

jlerch
Moderator
Moderator
Beiträge: 148
Registriert: 18. Okt 2005 14:45

Re: Preparation for the IFDS Exercise

Beitrag von jlerch » 2. Jun 2016 15:31

I want to add a quick hint on how to work on the exercise:

Start with the testcase for class Assignments. Look at the debug output to see which path edges are reaching to which bytecode instructions. Then think about if these are correct. If there is a path edge missing, check if you handled the preceding instruction. If there is a path edge where it should not be, check if you killed the fact at the preceding instruction.

Consequently, by starting with the Assignments testcase you have to first handle ASTORE instructions, then ALOAD.
Continue from here with the testcases InterproceduralInstanceBasedEdges and InterproceduralStaticEdges. I strongly recommend not to start handling fields nor arrays before you succeeded with these.


I will push my analysis implementation next week. This implementation is not complete (in the sense of handling all instructions), but capable of getting all tests green. Also, the next exercise will build on top of this exercise.

jlerch
Moderator
Moderator
Beiträge: 148
Registriert: 18. Okt 2005 14:45

Re: Preparation for the IFDS Exercise

Beitrag von jlerch » 3. Jun 2016 13:06

Just came across some bugs while extending my solution to the current exercise.
- OPAL returns the wrong number of pushed operands for FieldWriteAccess instructions
- OPAL contains a wrong implementation for Project.methodsWithBody
- If an invoke instruction does not consume all entries of the operand stack (e.g. this is usually the case for constructor calls), the returned fact's operand stack is missing those entries not consumed. I fixed that in DebuggableIFDSSolver

Both bugs in OPAL have already been fixed, thus you can simply pull the latest commits and then run sbt publishLocal on OPAL again. Alternatively, simply pull the APSA repository - i added some workarounds to avoid running into those bugs.
Unfortunately, the this issue required a change to Heros' IDESolver implementation. This means you have to pull the latest commit from Heros and run ant publish-local again.

However, those bugs are only problematic when you start handling fields with a field-based model.

eichberg
Moderator
Moderator
Beiträge: 448
Registriert: 25. Sep 2007 12:12
Kontaktdaten:

Re: Preparation for the IFDS Exercise

Beitrag von eichberg » 5. Apr 2017 15:03

Updated instructions for OPAL 0.8.10:

git clone https://github.com/Sable/heros.git
git clone https://github.com/stg-tud/apsa.git
cd opal
git checkout develop
sbt publishLocal
cd ../heros
cp ant.settings.template ant.settings
mkdir javadoc
ant publish-Local
cd ../apsa/2016/ifds/testcases
sbt test
cd ../ifds-exercise
sbt eclipse
Import projects IFDS-exercise and IFDS-testcases in Eclipse
Verify set-up: should compile without errors, some tests should succeed

Antworten

Zurück zu „Applied Static Analysis“