From 597605603a82b8c8b69b57339fd321eb3e122109 Mon Sep 17 00:00:00 2001 From: Mitch Phillips Date: Tue, 22 Mar 2022 18:33:44 +0000 Subject: [PATCH] [HWASan] Enable zero-initialization. Previously, we use to fill memory with 0xbe bytes. This caused a lot of problems that necessitated disablement. For example, 0xbe-filled mutexes are apparently locked, and there were a few instances of uninitialized-mutex use. Given that zero-fill is now the default behaviour, enable zero-init in HWASan as well. For now, only fill the first page. It would be preferable to fill the whole allocation, but I don't want to spin for too many cycles filling huge secondary pages. In future, we might change the behaviour to have an explicit "zero initialize" option that completely fills the primarily allocations, and knows it's unnecessary for the secondary. Bug: 226078464 Test: Boot w/ HWASan (done by presubmit robot) Change-Id: I7de3a7f9fa2fdeb5116e5bf6586babe4d06fcb91 --- cc/sanitize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc/sanitize.go b/cc/sanitize.go index f8661a6d1..3cf8b5832 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -76,7 +76,7 @@ var ( minimalRuntimeFlags = []string{"-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer,undefined", "-fno-sanitize-recover=integer,undefined"} hwasanGlobalOptions = []string{"heap_history_size=1023", "stack_history_size=512", - "export_memory_stats=0", "max_malloc_fill_size=0"} + "export_memory_stats=0", "max_malloc_fill_size=4096", "malloc_fill_byte=0"} ) type SanitizerType int