Align Group.Stats properly for 32-bit platforms.

Fixes golang/go#18334
This commit is contained in:
Brad Fitzpatrick 2016-12-16 00:27:18 +00:00
parent a6b377e340
commit d092608c06
2 changed files with 11 additions and 0 deletions

View File

@ -166,6 +166,8 @@ type Group struct {
// concurrent callers.
loadGroup flightGroup
_ int32 // force Stats to be 8-byte aligned on 32-bit platforms
// Stats are statistics on the group.
Stats Stats
}

View File

@ -27,6 +27,7 @@ import (
"sync"
"testing"
"time"
"unsafe"
"github.com/golang/protobuf/proto"
@ -443,5 +444,13 @@ func TestNoDedup(t *testing.T) {
}
}
func TestGroupStatsAlignment(t *testing.T) {
var g Group
off := unsafe.Offsetof(g.Stats)
if off%8 != 0 {
t.Fatal("Stats structure is not 8-byte aligned.")
}
}
// TODO(bradfitz): port the Google-internal full integration test into here,
// using HTTP requests instead of our RPC system.