static void *HwasanAllocate(StackTrace *stack, uptr size, uptr alignment,
bool zeroise) {
+ if (!size) return nullptr;
alignment = Max(alignment, kShadowAlignment);
size = RoundUpTo(size, kShadowAlignment);
num_descriptions_printed++;
}
+ if (t->AddrIsInStack(untagged_addr)) {
+ Printf("%s", d.Location());
+ Printf("Address %p is located in stack of thread %p\n", untagged_addr, t);
+ Printf("%s", d.Default());
+ num_descriptions_printed++;
+ }
});
if (!num_descriptions_printed)
--- /dev/null
+// Test basic malloc functionality.
+// RUN: %clang_hwasan %s -o %t
+// RUN: %run %t
+
+#include <stdlib.h>
+#include <assert.h>
+#include <sanitizer/hwasan_interface.h>
+
+int main() {
+ __hwasan_enable_allocator_tagging();
+ char *a1 = (char*)malloc(0);
+ assert(a1 == NULL); // may not be true for other malloc.
+}
#include <stdlib.h>
#include <assert.h>
+#include <sanitizer/hwasan_interface.h>
int main() {
+ __hwasan_enable_allocator_tagging();
char *x = (char*)realloc(nullptr, 4);
x[0] = 10;
x[1] = 20;
// CHECK: READ of size 1 at
// CHECK: #0 {{.*}} in f{{.*}}stack-oob.cc:14
- // CHECK: HWAddressSanitizer can not describe address in more detail.
+ // CHECK: is located in stack of threa
// CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in f
}
// CHECK: READ of size 1 at
// CHECK: #0 {{.*}} in main{{.*}}stack-uar.cc:16
- // CHECK: HWAddressSanitizer can not describe address in more detail.
+ // CHECK: is located in stack of thread
// CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
}