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
[fuzz] Assertion `VDecl->isLinkageValid()' failed. #22203
Comments
Less crazy test case: |
Still repros, cool test case. :) |
mentioned in issue #23431 |
@llvm/issue-subscribers-c-11 |
Both the original test case and the reduced test case still reproduce on Clang 16 with the following backtrace:
|
@llvm/issue-subscribers-clang-frontend |
Another reproducer from a Conor Hoekstra's CppNorth 2023 talk that is still crashing as of post-16 trunk. Reduced by C-Reduce:
Original example:
|
Crash looks the same as Aaron's above: https://godbolt.org/z/T41Gac6r5
|
I think the assertion is erroneous and the function should return false instead of assert failing. |
This is crashing b/c of this section in llvm-project/clang/lib/Parse/ParseStmt.cpp Lines 1269 to 1272 in 6b6312b
the change was introduced via 6db8501 I think it would make more sense to unconditionally return CC @akyrtzi @rjmccall who can hopefully help me understand the rationale for the change and maybe if we can rethink or I need to use the alternative fix. CC @zygoloid who may have some opinions on the right approach Note, there is a radar link but not really helpful since the larger rationale is not really laid out in the commit message nor the comment. |
The one-liner
|
The rationale is to preserve as much of the function body in the AST as mush as possible, even in the presence of erroneous code. This is particularly useful for libclang clients like an IDE. |
Making the type-checker just bail out and drop information earlier is more likely to avoid this kind of issue but can also impede effective recovery, as well as interfering with use cases like Argyrios's that would like to examine incomplete AST. I think you need to investigate to figure out what exactly is going wrong downstream if you create a lambda with an invalid compound stmt like this. Maybe there's something that sees an invalid ending source location and then skips some validation step? |
This seems like we should be using Recovery Expressions then CC @hokein @sam-mccall for some advice to make sure it makes sense here. |
The
+1, I think a fix is to figure out the related downstream place and teach it to handle this invalid case properly. |
Any progress on this? |
Extended Description
Fuzzing discovered that the attached test case, when given as input to
clang -fno-crash-diagnostics -std=c++11 -xc++ -c -emit-llvm
causes this assertion failure:
clang-3.6: tools/clang/lib/Sema/SemaDecl.cpp:8656: void clang::Sema::AddInitializerToDecl(clang::Decl *, clang::Expr *, bool, bool): Assertion `VDecl->isLinkageValid()' failed.
The text was updated successfully, but these errors were encountered: