-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[Clang][Frontend] Crash on clang::ASTContext::getRawCommentForDeclNoCacheImpl #68524
Comments
This commit resolves a crash issue in Clang's frontend caused while using the `-Wdocumentation` compiler flag. The flaw was due to the lack of necessary checks before the extraction of text between the comment and the declaration in the `ASTContext.cpp` file. Specifically, there was no verification to ensure that the second component of the declaration location's decomposition is not less than the comment's end offset. This could lead to an invalid length being passed to the `StringRef` constructor, triggering the crash. I have added a check to prevent this crash from occurring. Fixes llvm#68524.
@llvm/issue-subscribers-clang-frontend
LLVM revision: [eef35c2](https://github.com/llvm/llvm-project/commit/eef35c287ee093b3521c6c2b682d8da538ad28be)
I was trying to build Swift with clang, but clang crashes with the following error.
Link to the diagnostic files: AstContext-0f4f78.zip If I remove |
This is a regression that was introduced by commit 256a0b2 by @tahonermann Instead of papering over the problem, it's probably better to analyze the root cause for this or revert the offending patch. |
The same crash has been reported in #67979. I've started looking into it, but have not yet been able to put much time into it. I hope to get back to it this week. |
Avoids an LLVM crash introduced by upgrading Emscripten to 3.1.47. See upstream issue llvm/llvm-project#68524 for details.
Avoids an LLVM crash introduced by upgrading Emscripten to 3.1.47. See upstream issue llvm/llvm-project#68524 for details.
Avoids an LLVM crash introduced by upgrading Emscripten to 3.1.47. See upstream issue llvm/llvm-project#68524 for details.
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 llvm#68524 llvm#70550
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 llvm#68524 llvm#70550
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 Fixes llvm#68524 Fixes llvm#70550 (cherry picked from commit 5f4ee5a)
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 Fixes llvm#68524 Fixes llvm#70550 (cherry picked from commit 5f4ee5a)
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 Fixes llvm#68524 Fixes llvm#70550 (cherry picked from commit 5f4ee5a)
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 Fixes llvm#68524 Fixes llvm#70550 (cherry picked from commit 5f4ee5a)
This crash is basically caused by calling `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different files. A reduced reproducer is provided in this patch. After the source locations for instantiations of funtion template are corrected in the commit 256a0b2, the variable `CommitsInThisFile` in the function `ASTContext::attachCommentsToJustParsedDecls` would refer to the source file rather than the header file for implicit function template instantiation. Therefore, in the first loop in `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be adjusted for relevant scenarios like the second loop. Fixes llvm#67979 Fixes llvm#68524 Fixes llvm#70550 (cherry picked from commit 5f4ee5a)
LLVM revision: eef35c287ee0
I was trying to build Swift with clang, but clang crashes with the following error.
(Originally, I ran clang with Chromium's clang and got a crash. So I tried to build clang by myself and run it, but it still crashes.)
Link to the diagnostic files: AstContext-0f4f78.zip
If I remove
-Wdocumentation
flag, it works well.The text was updated successfully, but these errors were encountered: