Skip to content
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

Tell the different objects from custom alloc functions with SUPA #3

Open
honghai0924 opened this issue Nov 6, 2018 · 1 comment
Open
Labels
question Further information is requested

Comments

@honghai0924
Copy link

Hi Yulei,
As we discussed in SVF-tools/SVF#109, I tried SUPA for context-sensitive analysis with code below:

#include <stdlib.h>

void my_malloc(char ** p,unsigned size){
    *p = malloc(size);
}

void use1(char *s1){
    char c1 = s1[0];
}

void use2(char *s2){
    char c2 = s2[1];
}

void f(void){
    char *p1,*p2,*p3,*p4,*p5,*p6;
    p1 = malloc(1);
    p2 = malloc(2);
    my_malloc(&p3,3);
    my_malloc(&p4,4);
    p5 = p3;
    p6 = p4;
    use1(p5);
    use2(p6);
}

I used wpa to get the constraint graph as below.
image

Then I used

dvf -cxt -query=all -maxcxt=3 -cxtbg=10000 -flowbg=10000 -print-query-pts alloc_test.bc

to get points to result.

......
##<> Source Loc:
Ptr 81 		PointsTo: { 18 }

!!Target NodeID 18	 [<call> Source Loc: ]
##<> Source Loc:
Ptr 83 		PointsTo: { 18 }

!!Target NodeID 18	 [<call> Source Loc: ]
##<> Source Loc:
Ptr 85 		PointsTo: { 18 }

!!Target NodeID 18	 [<call> Source Loc: ]
##<> Source Loc:
Ptr 87 		PointsTo: { 18 }

!!Target NodeID 18	 [<call> Source Loc: ]

From the result above, I saw Ptr 81,83,85,87 all point to PagNode 18, which makes them aliases. But pointer p5 and p6 should not be aliases.

Is that supposed to be right? Or am I doing something wrong here?

@yuleisui
Copy link
Collaborator

yuleisui commented Nov 6, 2018

-print-query-pts will print insensitive results. For context-sensitive analysis please use https://github.com/SVF-tools/SVF/blob/ab806b876e1e6ec1e7fb32eb5052881aa62775d8/include/MemoryModel/PointerAnalysis.h#L374
to obtain points-to targets together with their calling contexts.

For your case, you may wish to refer to alias function to get the non-alias results:

llvm::AliasResult DDAPass::alias(const Value* V1, const Value* V2) {

@yuleisui yuleisui added the question Further information is requested label Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants