Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active February 17, 2017 10:13
Show Gist options
  • Save steipete/4d7550244ef31b5c5c0cabf11a1dd191 to your computer and use it in GitHub Desktop.
Save steipete/4d7550244ef31b5c5c0cabf11a1dd191 to your computer and use it in GitHub Desktop.
Apple DTS setting ASAN_OPTIONS for XCTest (Follow-up: 646910755). rdar://28103342 see http://openradar.appspot.com/28103342
PLATFORM AND VERSION
iOS
Xcode 8b6
DESCRIPTION OF PROBLEM
I'm trying to customize ASAN_OPTIONS based on
https://github.com/google/sanitizers/wiki/AddressSanitizer
Specifically, I am trying to run without the new odr detection because this seems to be buggy:
http://prod.lists.apple.com/archives/xcode-users/2016/Aug/msg00018.html
>HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
See attached sample project. Xcode correctly merges it's own ASAN settings with the settings in the environment variable when the app runs normally, but does not do that when I run tests.
I'm using following debug code to make displaying the env variables convenient:
+ (void)load {
NSLog(@"%@", NSProcessInfo.processInfo.environment);
}
This is the output when tests run:
https://gist.github.com/steipete/f9b6c423254f94a3bdbedf865fdadc32
2016-08-29 22:46:37.727 AsanOptionTest[97751:1426969] {
"ASAN_OPTIONS" = "abort_on_error=1:color=never";
"ASAN_TEST" = "asan-forwarding-works=1";
This ist the output when the app runs:
https://gist.github.com/steipete/a7bec36088f3db8d340aa647fc990c13
AddressSanitizer debugger support is active. Memory error breakpoint has been installed and you can now use the 'memory history' command.
2016-08-29 22:53:41.898 AsanOptionTest[98221:1438355] {
"ASAN_OPTIONS" = "abort_on_error=1:color=never:detect_odr_violation=0:asan_option_radar_test_setting=1";
"ASAN_TEST" = "asan-forwarding-works=1";
A regular run correctly merges the default settings with custom settings - this does not happen for tests. Is this a bug? Can you provide a workaround so we can set asan options while running tests?
I tried if a TestHost makes any difference in our full project - it does not. Tried many variations. Tried manually running with -fsanitize=address and linker flag -lclang_rt.asan_iossim_dynamic but I didn't get it to run (i tried to work around Xcode)
Thanks for helping here! Need to track down a memory corruption in the tests and asan will be immensely helpful, once we get it to run.
Project to test: https://cl.ly/2c1j0L1V2f1T
STEPS TO REPRODUCE
Download project: https://cl.ly/2c1j0L1V2f1T
Run regular, observe log.
Run tests, observe log.
@steipete
Copy link
Author

This is fixed in Xcode 8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment