forked from OSchip/llvm-project
sanitizer_common: tighten on_print hook test
The new tsan runtime does not support arbitrary forms of recursing into the runtime from hooks. Disable instrumentation of the hook and use write instead of fwrite (calls malloc internally). The new version still recurses (write is intercepted), but does not fail now (the issue at hand was malloc). Depends on D112601. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D112602
This commit is contained in:
parent
f50cee2f4b
commit
eae047afe0
|
@ -8,21 +8,25 @@
|
|||
// UNSUPPORTED: android
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
FILE *f;
|
||||
int f;
|
||||
volatile void *buf;
|
||||
volatile char sink;
|
||||
|
||||
extern "C" void __sanitizer_on_print(const char *str) {
|
||||
fprintf(f, "%s", str);
|
||||
fflush(f);
|
||||
__attribute__((disable_sanitizer_instrumentation)) extern "C" void
|
||||
__sanitizer_on_print(const char *str) {
|
||||
write(f, str, strlen(str));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
assert(argc >= 2);
|
||||
f = fopen(argv[1], "w");
|
||||
f = open(argv[1], O_WRONLY);
|
||||
|
||||
// Use-after-free to trigger ASan/TSan reports.
|
||||
void *ptr = malloc(1);
|
||||
|
|
Loading…
Reference in New Issue