llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

ProgramState::assumeInBound does not handle large values well

Open llvmbot opened this issue 11 years ago • 6 comments

Bugzilla Link 25284
Resolution WORKSFORME
Resolved on Jun 26, 2020 10:16
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @Charusso,@ASDenysPetrov,@haoNoQ

Extended Description

The ProgramState::assumeInBound() does not handle large values well.

I demonstrate by showing a FP, example code:

void f() {
   int a[1LL<<40];
   a[13] = 0;
}

Clang output:

1.c:5:11: warning: Access out-of-bound array element (buffer overflow)
    a [13]=0;
    ~~~~~~^

llvmbot avatar Oct 22 '15 15:10 llvmbot

This probably got fixed by https://reviews.llvm.org/D16063.

haoNoQ avatar Jun 26 '20 17:06 haoNoQ

I have tried to reproduce the issue with clang-8, because my patch (https://reviews.llvm.org/D69599) from clang-10 potentially could fix this by storing the size symbol. However, it has been fixed before clang-8, so I think it is already fixed long ago. @​NoQ, could we close this?

Charusso avatar Jun 26 '20 13:06 Charusso

I couldn't reproduce it on the latest build. Looks like it could be fixed by https://reviews.llvm.org/D69599

ghost avatar Jun 12 '20 15:06 ghost

I investigated this to see if I can solve this.

If the type parameter to ProgramState::assumeInBound() is empty it will just use Ctx.IntTy. Is this wanted? Would it be ok if I try to look at the UpperBound and NumElements and choose a Ctx.*Ty?

llvmbot avatar Oct 22 '15 16:10 llvmbot

btw.. A little nit. I saw now that the error message points at the '='. It would be better imho if it pointed at the '['.

llvmbot avatar Oct 22 '15 15:10 llvmbot

assigned to @tkremenek

llvmbot avatar Oct 22 '15 15:10 llvmbot