Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang::DominatorTree::buildDominatorTree crashes for codes with infinite while loops #39159

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR40187
Status NEW
Importance P normal
Reported by Aaditya Naik (aadi.naik@gmail.com)
Reported on 2018-12-30 09:36:20 -0800
Last modified on 2018-12-30 19:51:40 -0800
Version 7.0
Hardware PC Linux
CC ditaliano@apple.com, htmldeveloper@gmail.com, kubakuderski@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments domtreebug.tar.gz (1512 bytes, application/gzip)
Blocks
Blocked by
See also
Created attachment 21281
A tar of the folder containing the RAV code as well as some test cases

The buildDominatorTree function gives a segmentation fault when trying to build
a dominator tree within a RecursiveASTVisitor Visit function for a code
containing an infinite loop (specifically where the condition is 1) like this
code-
int main() {
    int x, y, z;
    x = 10;
    while(1) {
        x++;
        if(x == 100) {
            break;
        }
    }
    return 0;
}

Assigning the value 1 to a variable and using the variable as a condition does
not cause an issue-

int main() {
    int x, y, z;
    x = 10;
    y = 1;
    while(y) {
        x++;
        if(x == 100) {
            break;
        }
    }
    return 0;
}

The code for reproducing the error as well as the test cases are in the tar file

Found when using Clang 7 and LLVM 7 installed from the Debian packages
Quuxplusone commented 5 years ago

Attached domtreebug.tar.gz (1512 bytes, application/gzip): A tar of the folder containing the RAV code as well as some test cases