diff options
| author | Russ Cox <rsc@golang.org> | 2014-12-22 10:53:51 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-01-06 00:26:35 +0000 |
| commit | dcec123a4923437242c52d2693ace80d2f3c704e (patch) | |
| tree | 9f1d6a2a5bcf75e86e84a657a7aca5b522947ab5 /src/runtime/malloc2.go | |
| parent | 3191a235158233bb6f6d960d7ae0cb925606f817 (diff) | |
| download | go-dcec123a4923437242c52d2693ace80d2f3c704e.tar.xz | |
runtime: add GODEBUG wbshadow for finding missing write barriers
This is the detection code. It works well enough that I know of
a handful of missing write barriers. However, those are subtle
enough that I'll address them in separate followup CLs.
GODEBUG=wbshadow=1 checks for a write that bypassed the
write barrier at the next write barrier of the same word.
If a bug can be detected in this mode it is typically easy to
understand, since the crash says quite clearly what kind of
word has missed a write barrier.
GODEBUG=wbshadow=2 adds a check of the write barrier
shadow copy during garbage collection. Bugs detected at
garbage collection can be difficult to understand, because
there is no context for what the found word means.
Typically you have to reproduce the problem with allocfreetrace=1
in order to understand the type of the badly updated word.
Change-Id: If863837308e7c50d96b5bdc7d65af4969bf53a6e
Reviewed-on: https://go-review.googlesource.com/2061
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/malloc2.go')
| -rw-r--r-- | src/runtime/malloc2.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/malloc2.go b/src/runtime/malloc2.go index 535e7cace3..3766da886f 100644 --- a/src/runtime/malloc2.go +++ b/src/runtime/malloc2.go @@ -434,6 +434,15 @@ type mheap struct { arena_end uintptr arena_reserved bool + // write barrier shadow data+heap. + // 64-bit systems only, enabled by GODEBUG=wbshadow=1. + shadow_enabled bool // shadow should be updated and checked + shadow_reserved bool // shadow memory is reserved + shadow_heap uintptr // heap-addr + shadow_heap = shadow heap addr + shadow_data uintptr // data-addr + shadow_data = shadow data addr + data_start uintptr // start of shadowed data addresses + data_end uintptr // end of shadowed data addresses + // central free lists for small size classes. // the padding makes sure that the MCentrals are // spaced CacheLineSize bytes apart, so that each MCentral.lock |
