From 17cd42b0b391d04900cd51dee74abc92bac85660 Mon Sep 17 00:00:00 2001 From: WGH Date: Mon, 25 Feb 2019 09:47:40 +0300 Subject: [PATCH] Reorder Scanner fields to fix alignment issues (#464) Go doesn't always guarantee 64-bit alignment of 64-bit integer, which leads to crashes when atomic operations are used on them on certain platforms (e.g. ARM). This problem is described here: https://golang.org/pkg/sync/atomic/#pkg-note-BUG By putting these fields first, proper alignment will be guaranteed. https://github.com/golang/go/issues/599 https://github.com/golang/go/issues/23345 --- scanner/scanner.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scanner/scanner.go b/scanner/scanner.go index af6823e4c7..d3da2d2420 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -59,10 +59,8 @@ func DefaultScannerOptions() *ScannerOptions { // Scanner is a tool to scan all the entries in a CT Log. type Scanner struct { - fetcher *Fetcher - - // Configuration options for this Scanner instance. - opts ScannerOptions + // N.B. 64-bit fields must be first due to + // https://golang.org/pkg/sync/atomic/#pkg-note-BUG // Counters of the number of certificates scanned and matched. certsProcessed int64 @@ -73,6 +71,11 @@ type Scanner struct { unparsableEntries int64 entriesWithNonFatalErrors int64 + + fetcher *Fetcher + + // Configuration options for this Scanner instance. + opts ScannerOptions } // entryInfo represents information about a log entry.