llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.78k stars 11.9k forks source link

clang frontend crash due to an exponential complexity of typo corrector #43925

Open llvmbot opened 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 44580
Version unspecified
OS All
Attachments typos.cpp from description
Reporter LLVM Bugzilla Contributor
CC @dwblaikie,@DougGregor,@zygoloid,@Weverything

Extended Description

Compiling typos.cpp ends with an "LLVM ERROR: out of memory"

typos.cpp is a very simple file with n=10 int definitions and a function call with n arguments. When clang analyzes this file it tries to correct typos in it. In order to do this it calls method clangSema::SemaExprCXX.cpp::CheckAndAdvanceTypoExprCorrectionStreams

The problem is that amount of calls is around 8^(n-1), which leads to a crash or infinitely long waiting time.

Endilll commented 1 year ago

Still hanging as of post-17 trunk: https://godbolt.org/z/4PfT54sjG

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend