[PATCH] D41664: Remove test which assumed array cookies can't be poisoned when using an operator new defined in a class

Filipe Cabecinhas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 2 05:57:08 PST 2018


filcab created this revision.
filcab added reviewers: kcc, eugenis.
Herald added subscribers: Sanitizers, kubamracek.

The original commit doesn't provide any rationale for this test, just
that "the cookie should not be poisoned" (why?).


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D41664

Files:
  test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cc


Index: test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cc
===================================================================
--- test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Test that we do not poison the array cookie if the operator new is defined
-// inside the class.
-// RUN: %clangxx_asan  %s -o %t && %run %t
-//
-// XFAIL: arm
-
-// UNSUPPORTED: ios
-
-#include <new>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <assert.h>
-struct Foo {
-  void *operator new(size_t s) { return Allocate(s); }
-  void *operator new[] (size_t s) { return Allocate(s); }
-  ~Foo();
-  static void *allocated;
-  static void *Allocate(size_t s) {
-    assert(!allocated);
-    return allocated = ::new char[s];
-  }
-};
-
-Foo::~Foo() {}
-void *Foo::allocated;
-
-Foo *getFoo(size_t n) {
-  return new Foo[n];
-}
-
-int main() {
-  Foo *foo = getFoo(10);
-  fprintf(stderr, "foo  : %p\n", foo);
-  fprintf(stderr, "alloc: %p\n", Foo::allocated);
-  assert(reinterpret_cast<uintptr_t>(foo) ==
-         reinterpret_cast<uintptr_t>(Foo::allocated) + sizeof(void*));
-  *reinterpret_cast<uintptr_t*>(Foo::allocated) = 42;
-  return 0;
-}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41664.128413.patch
Type: text/x-patch
Size: 1222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180102/b5a91c7d/attachment.bin>


More information about the llvm-commits mailing list