Skip to content

Commit

Permalink
Reorder Scanner fields to fix alignment issues (#464)
Browse files Browse the repository at this point in the history
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.

golang/go#599
golang/go#23345
  • Loading branch information
WGH- authored and daviddrysdale committed Feb 25, 2019
1 parent 8c58afd commit 17cd42b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 17cd42b

Please sign in to comment.