Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

SAILR pathological case for jump threading #5753

@rhelmot

Description

@rhelmot

Description

Original source:

int main(int argc, char **argv) {
    bool v1 = getbool();
    bool v2 = getbool();
    bool v3 = getbool();

    if (v1) {
        puts("A");
        if (v2) {
            puts("B");
        }
    }
    if (v2 || v3) {
        puts("C");
    }
    puts("done");
    return 0;
}

python -m angr -- test decompile --functions main --preset full

int main()                                                                                          
{                                                                                                   
    char v1;  // bpl                                                                                
    char v2;  // bl                                                                                 
    char v3;  // r12b                                                                               
                                                                                                    
    v1 = getbool();                                                                                 
    v2 = getbool();                                                                                 
    v3 = getbool();                                                                                 
    if (v1)                                                                                         
    {                                                                                               
        puts("A");                                                                                  
        if (!v2)                                                                                    
        {                                                                                           
LABEL_401079:                                                                                       
            if (!v3)                                                                                
            {                                                                                       
                puts("done");                                                                       
                return 0;                                                                           
            }                                                                                       
        }                                                                                           
        else                                                                                        
        {                                                                                           
            puts("B");                                                                              
        }                                                                                           
    }                                                                                               
    else if (!v2)                                                                                   
    {                                                                                               
        goto LABEL_401079;                                                                          
    }                                                                                               
    puts("C");                                                                                      
    puts("done");                                                                                   
    return 0;                                                                                       
}

presets fast and basic are slightly different but still not good.

Steps to reproduce the bug

test.gz

Environment

No response

Additional context

The compiler inserts a goto from after puts("B") to after the second v2 check. This is not being deoptimized correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions