view compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c @ 173:0572611fdcc8 llvm10 llvm12

reorgnization done
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:55:54 +0900
parents
children 1f2b6ac9f198
line wrap: on
line source

// RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=random_tags=1 %run %t
// REQUIRES: stable-runtime

#include <pthread.h>
#include <sanitizer/hwasan_interface.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void *ThreadFn(void *) {
  strerror_l(-1, 0);
  __hwasan_enable_allocator_tagging();
  // This will trigger memory deallocation in __strerror_thread_freeres,
  // at a point when HwasanThread is already gone.
}

int main() {
  pthread_t t;
  pthread_create(&t, NULL, ThreadFn, NULL);
  pthread_join(t, NULL);
  return 0;
}