Workaround alloc-dealloc-mismatch error on ASan device boot.

/proc/self/environ inaccessible in SurfaceFlinger
=> ASan fails to read ASAN_OPTIONS => alloc-dealloc-mismatch bug is not
suppressed and prevents the device from booting.

This is not perfect because, by enabling it in asan build only, the first several attempts to start
surfaceflinger fail while the /data partition is being encrypted. On the other hand, this does not affect
user builds, and device eventually gets up anyway.

BUG=b/30067360

Change-Id: Ieaa37ff7768a11450ea33fee1f7d70a41b246c6a
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fdc3650..5742f6f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -88,6 +88,19 @@
 
 EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
 
+// Workaround for b/30067360: /proc/self/environ inaccessible in SurfaceFlinger
+// => ASan fails to read ASAN_OPTIONS => alloc-dealloc-mismatch bug is not
+// suppressed and prevents the device from booting.
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+#if __has_feature(address_sanitizer)
+__attribute__((visibility("default")))
+extern "C" const char* __asan_default_options() {
+  return "alloc_dealloc_mismatch=0";
+}
+#endif
+
 namespace android {
 
 // This is the phase offset in nanoseconds of the software vsync event