Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
I can see that a very simple ObjC test does not work with O2 (on Linux).
% cat foo.mm
#include <stdlib.h>
int main(int argc, char **argv) {
int *a = (int*)malloc(10 * sizeof(int));
int res = a[argc + 10];
free(a);
return res;
}
% clang -O1 -ObjC foo.mm -faddress-sanitizer && ./a.out 2>&1 | grep ERROR
==11562== ERROR: AddressSanitizer heap-buffer-overflow on address
0x7f91d5144fac at pc 0x401e90 bp 0x7fffccf6c0b0 sp 0x7fffccf6c0a8
% clang -O2 -ObjC foo.mm -faddress-sanitizer && ./a.out 2>&1 | grep ERROR
%
Original comment by konstant...@gmail.com
on 30 Jan 2012 at 11:06
And most of the asan GCD tests pass if built with -O1.
I guess the optimizer is being too smart.
Original comment by konstant...@gmail.com
on 30 Jan 2012 at 11:12
r149296 fixes the problem by not letting the optimizer to optimize away the
test code.
Original comment by konstant...@gmail.com
on 30 Jan 2012 at 11:29
Original issue reported on code.google.com by
ramosian.glider@gmail.com
on 30 Jan 2012 at 2:46