Open langston-barrett opened 1 year ago
@llvm/issue-subscribers-clang-frontend
This is a good bug report while the code is invalid we should generate a proper diagnostic like gcc does: https://godbolt.org/z/PrEvnfKK8
This is probably an easy mistake for someone to make if they are using the attribute the first time or typo the index etc
On the other hand we don't have the bandwidth for mass submission of fuzzer bugs but carefully curated bug submissions are definitely welcome @AaronBallman do you have additional feedback on this?
Should be an easy fix, just compare the Idx
with getFunctionOrMethodNumParams(D)
.
@llvm/issue-subscribers-good-first-issue
This is a good bug report while the code is invalid we should generate a proper diagnostic like gcc does: https://godbolt.org/z/PrEvnfKK8
This is probably an easy mistake for someone to make if they are using the attribute the first time or typo the index etc
Agreed, this is a good issue to fix (and shouldn't be too challenging).
On the other hand we don't have the bandwidth for mass submission of fuzzer bugs but carefully curated bug submissions are definitely welcome @AaronBallman do you have additional feedback on this?
You nailed it -- if the fuzzer produces code that could be reasonably plausible for a user to write (like this one), then it's a great bug report to file. For implausible code, we'd be fine accepting a patch to fix the issue if it's a crash but would probably not prioritize the bug too highly otherwise. (If the code is borderline, I'd say go ahead and add an issue for it.)
Thanks for the feedback @shafik, @AaronBallman! I'll endeavor to post useful bugs as I find them, feel free to let me know if they're straying outside of the realm of reports you want.
This test case exhibits a similar issue; not sure whether to file a separate bug or just note it here.
void __attribute__ ((alloc_size (2, 3))) *test(int i, ...);
Eh, let's note it here -- it's a semi-distinct issue, but it's the same kind of problem between both attributes (so the fix for one might fix the other, depending on how we decide to address it).
Would you mind editing the summary and title though, so it's clear there's two-ish issues here?
Hello @tbaederr , what does this mean >Should be an easy fix, just compare the Idx with getFunctionOrMethodNumParams(D)
.I am able to track to the function where the error is emerging which is this
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx) {
if (const FunctionType *FnTy = D->getFunctionType())
return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
if (const auto *BD = dyn_cast<BlockDecl>(D))
return BD->getParamDecl(Idx)->getType();
return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
}
What changes should I make for the comparison?
That is not the function where the error is reported though. You need to find the place where that happens and check if the given index is greater than the number of parameters.
The crash emerges from the assertion failing in the getParamType after being called in the above function.
QualType getParamType(unsigned i) const {
assert(i < getNumParams() && "invalid parameter index");
return param_type_begin()[i];
}
I guess my task is to return a nice warning or error message maybe > attribute argument value '2' exceeds the number of function parameters 1
.
Where can I find classes and function for creating Warmng or Error messages? I am a begginer that why I may ask very basic questions. Bare with me.
Even if I compare the Idx and the result of getFunctionOrMethodNumParams(D) in the getFunctionOrMethodParamType function above , I still can't use an assertion since it will cause a crush.
Yes, you need to do that before the assertion is reached, and from the function that calls getFunctionOrMethodParamType
Even if I compare the Idx and the result of getFunctionOrMethodNumParams(D) in the getFunctionOrMethodParamType function above , I still can't use an assertion since it will cause a crush.
I am also working on this issue. Can we collaborate?
Sure.
From brief investigation it looks like we want the bad
function here to produce the same error message as GCC: https://godbolt.org/z/761MhbPYP
Adding posted patch link - https://reviews.llvm.org/D147037
This is a fuzzer-generated bug. Feel free to close if you're not interested in such reports. If you would like more reports of fuzzer-generated bugs, let me know and I can post them. I read the bug report guidelines, and did not find information on whether or not fuzzer-generated bugs were welcome.
Clang crashes on this program:
with this message (Godbolt):
This looks like a Clang problem, because it still happens with
-emit-llvm -Xclang -disable-llvm-passes
.I searched like so for duplicates, but didn't find any: