Skip to content

Instantly share code, notes, and snippets.

@steipete
Created October 18, 2016 00:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steipete/fc2d68c9f7d54f024c36d094e39962fd to your computer and use it in GitHub Desktop.
Save steipete/fc2d68c9f7d54f024c36d094e39962fd to your computer and use it in GitHub Desktop.
//
// TSAN_OPTIONS.h
// PSPDFKit
//
// Copyright © 2016 PSPDFKit GmbH. All rights reserved.
// Example code licensed under MIT. Enjoy!
//
#if __has_feature(thread_sanitizer)
#include <TargetConditionals.h>
#if TARGET_OS_OSX
// macOS app structure is weird :)
#define TSANSUPPPATH "../Resources/ThreadSanitizerSuppressions.supp"
#else
#define TSANSUPPPATH "ThreadSanitizerSuppressions.supp"
#endif
/*
See ASAN_OPTIONS for the radar list.
*/
__attribute__((visibility("default"))) __attribute__((no_sanitize_address))
FOUNDATION_EXPORT const char *__tsan_default_options(void);
FOUNDATION_EXPORT const char *__tsan_default_options() {
/*
https://github.com/google/sanitizers/wiki
verbosity: can't hurt :)
suppressions: You can either specify the full path to the file or the path of the file relative to the location of your executable.
http://clang.llvm.org/docs/AddressSanitizer.html#suppressing-reports-in-external-libraries
report_thread_leaks=0
We do not clean up our worker threads in core so this needs to be suppressed.
Optionally useful: halt_on_error=0
*/
return "verbosity=0:report_thread_leaks=0:halt_on_error=1:suppressions=" TSANSUPPPATH;
}
__attribute__((constructor)) static void PSPDFTSANSettingsPrinter(void) {
NSLog(@"ThreadSanitizer Enabled. Settings: %s (See TSAN_OPTIONS.h)", __tsan_default_options());
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment