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
A wrong call graph but pointsTo analysis result is correct #546
Comments
Hi @StevenArzt , it looks I can reproduce this issue on other apps. Is it because when the pointsTo result on the base of an instance invocation is pretty much similar (or exactly the same) to a CHA result, soot will drop all edges at this call site? Such a design does have benefits (e.g., reduce FPs) but this is just my guess. |
We don't have an explicit optimiaztion to drop edges. FlowDroid, in its default configuration, completely relies on SPARK for application code. The taint wrapper uses the declared callee to find the appropriate summary, but that's not relevant for app code, as there is no summary definition for app code. I'm not sure why the callgraph is wrong. SPARK builds the CG on top of the propagated points-to information, i.e., the output of SPARK is a combination of points-to and CG. I'd suggest to look at points-to and CG after each round of callgraph construction, since we run the callback analysis (and thus CG/points-to analysis) iteratively. If it's broken right from the start, that might be a bug in SPARK. If it gets broken later one, it might be a weird issue with how we run the iterative CG/points-to combination based on SPARK. I'm afraid I don't have the time at the moment to debug into this on my own. |
Hi @StevenArzt , thanks for your reply. I follow your advice and it seems the bug might be in SPARK. I print the pointsTo result and the call graph in each round. It turns out the pointsTo result is |
This raises two questions. Firstly, why do we get Secondly, why is the callgraph not updated? That is strange as well. The CG after the first round should point to both methods given that pointsTo is any-subtype. With this debugging result, I would rather expect an FP than a FN. Even if we don't get any edge in the first round (for whatever reason), the second round should fix it. We get a new points-to set, hence the CG should be called again (recall that SPARK calls back and forth between points-to analysis and CG until a fixpoint is reached) and the edge to |
Hi @StevenArzt , I found the root cause. The bug is caused by modifiers. It turns out if I change
I guess it is because Maybe we can put the dummy main of a component into the same package of that component, rather than just put all dummy mains in |
I'm slightly confused. The dummy main method should only call If the call from |
Hi @StevenArzt , I have narrowed down the issue. It seems the problem lies in When I set If I set |
Hi @StevenArzt , it turns out this may be a stupid bug... It is caused at two call cites on
The declaration of
Obviously, the 1st parameter should be the class to check and the 2nd parameter should be the class declaring the method got from an invoke expression. But when So after switching 1st and 2nd arguments like this
The result call graph is correct. Could you check if my investigation is correct? One thing I don't understand is why this commit introduce this "bug"? |
That commit was apparently part of the effort to add support for default methods in interfaces. We should check that the fix doesn't introduce problems with default methods. I'd rather assume oversight than an intended change, though. |
Hold on @StevenArzt , it looks the fix proposed by me introduces other issues. For example
Although I can see The call graph is correct if I do not apply the fix. I am confused about this because when I call |
Close as fixed in Soot |
Hi @StevenArzt , I found FlowDroid manifest a weird bug on this specific app (apk). It turns out the pointsTo analysis is correct but the call graph is not correct.
I simplify the inheritance hierarchy that is related to the bug as follows.
CycleStreets
extendsMainNavDrawerActivity
, whose methodonNewVersion
is then overridden byCycleStreets
.Then I print the call graph, the expected result should be
However, the actual output is
I also locate the callsite of
onNewVersion()
and see the pointTo results of the base local (i.e., r0 atvirtualinvoke r0.<net.cyclestreets.MainNavDrawerActivity: void onNewVersion()>()
). I found the only possible types ofr0
isCycleStreets
, which means the pointsTo result is correct. In this case, why the call graph is not correct?BTW, I also make my own app to simulate this inheritance structure and it looks the call graph is correct. So the bug can only be reproduced on that specific app. Could you take a look at this issue? Thanks in advance!
The text was updated successfully, but these errors were encountered: