[llvm-commits] [compiler-rt] r149296 - in /compiler-rt/trunk/lib/asan/tests: asan_mac_test.mm asan_test.cc
Alexander Potapenko
glider at google.com
Tue Jan 31 00:55:25 PST 2012
I dislike the idea of using noinline functions instead of actual
memory accesses.
This may mask problems with uninstrumented accesses, see
http://code.google.com/p/address-sanitizer/issues/detail?id=33#c9
On Tue, Jan 31, 2012 at 3:23 AM, Kostya Serebryany <kcc at google.com> wrote:
> Author: kcc
> Date: Mon Jan 30 17:23:26 2012
> New Revision: 149296
>
> URL: http://llvm.org/viewvc/llvm-project?rev=149296&view=rev
> Log:
> [asan] fix issue 35: don't let the optimizer to optimize the test code away.
>
> Modified:
> compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm
> compiler-rt/trunk/lib/asan/tests/asan_test.cc
>
> Modified: compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm?rev=149296&r1=149295&r2=149296&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm (original)
> +++ compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm Mon Jan 30 17:23:26 2012
> @@ -32,6 +32,10 @@
> CFAllocatorDeallocate(kCFAllocatorMallocZone, mem);
> }
>
> +__attribute__((noinline))
> +void access_memory(char *a) {
> + *a = 0;
> +}
>
> // Test the +load instrumentation.
> // Because the +load methods are invoked before anything else is initialized,
> @@ -51,7 +55,8 @@
>
> +(void) load {
> for (int i = 0; i < strlen(kStartupStr); i++) {
> - volatile char ch = kStartupStr[i]; // make sure no optimizations occur.
> + // TODO: this is currently broken, see Issue 33.
> + // access_memory(&kStartupStr[i]); // make sure no optimizations occur.
> }
> // Don't print anything here not to interfere with the death tests.
> }
> @@ -66,7 +71,7 @@
>
> void worker_do_crash(int size) {
> char * volatile mem = malloc(size);
> - mem[size] = 0; // BOOM
> + access_memory(&mem[size]); // BOOM
> free(mem);
> }
>
> @@ -162,7 +167,7 @@
> dispatch_source_set_timer(timer, milestone, DISPATCH_TIME_FOREVER, 0);
> char * volatile mem = malloc(10);
> dispatch_source_set_event_handler(timer, ^{
> - mem[10] = 1;
> + access_memory(&mem[10]);
> });
> dispatch_resume(timer);
> sleep(2);
> @@ -186,7 +191,7 @@
> dispatch_source_cancel(timer);
> });
> dispatch_source_set_cancel_handler(timer, ^{
> - mem[10] = 1;
> + access_memory(&mem[10]);
> });
> dispatch_resume(timer);
> sleep(2);
> @@ -197,7 +202,7 @@
> dispatch_group_t group = dispatch_group_create();
> char * volatile mem = malloc(10);
> dispatch_group_async(group, queue, ^{
> - mem[10] = 1;
> + access_memory(&mem[10]);
> });
> dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
> }
>
> Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=149296&r1=149295&r2=149296&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
> +++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Mon Jan 30 17:23:26 2012
> @@ -1668,7 +1668,7 @@
> *Ident(&a) = *Ident(&a);
> }
>
> - __attribute__((no_address_safety_analysis))
> +__attribute__((no_address_safety_analysis))
> static void NoAddressSafety() {
> char *foo = new char[10];
> Ident(foo)[10] = 0;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
--
Alexander Potapenko
Software Engineer
Google Moscow
More information about the llvm-commits
mailing list