From 7b572d500b0702f1ea30a47083ce2e1e5c61edba Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 26 Oct 2017 11:55:02 -0400 Subject: [PATCH] route: work around macOS kernel bug The macOS kernel reliably crashes in a repeated TestRouteMessage. Putting some extra padding into the request buffer avoids the crash. This will do as workaround; the kernel bug will be reported to Apple separately. Fixes golang/go#22456. Change-Id: I789d3d57fbc511016d9f4a3fa7662d6c7642f137 Reviewed-on: https://go-review.googlesource.com/73690 Run-TryBot: Russ Cox Reviewed-by: Austin Clements TryBot-Result: Gobot Gobot --- route/route_classic.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/route/route_classic.go b/route/route_classic.go index 61b2bb4a..02fa6883 100644 --- a/route/route_classic.go +++ b/route/route_classic.go @@ -6,7 +6,10 @@ package route -import "syscall" +import ( + "runtime" + "syscall" +) func (m *RouteMessage) marshal() ([]byte, error) { w, ok := wireFormats[m.Type] @@ -14,6 +17,11 @@ func (m *RouteMessage) marshal() ([]byte, error) { return nil, errUnsupportedMessage } l := w.bodyOff + addrsSpace(m.Addrs) + if runtime.GOOS == "darwin" { + // Fix stray pointer writes on macOS. + // See golang.org/issue/22456. + l += 1024 + } b := make([]byte, l) nativeEndian.PutUint16(b[:2], uint16(l)) if m.Version == 0 {