aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/go-patches/0014-runtime-make-write-into-function-pointer.patch
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-12-03 13:40:02 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-12-09 16:01:47 +0100
commit450189162e15c813713b5c3a5208bdb6380c17f8 (patch)
tree40c4d93b70a705f50559a72aac135b6a6129336e /go-patches/0014-runtime-make-write-into-function-pointer.patch
parentmanager: use service subscriptions on win 8+ (diff)
downloadwireguard-windows-450189162e15c813713b5c3a5208bdb6380c17f8.tar.xz
wireguard-windows-450189162e15c813713b5c3a5208bdb6380c17f8.zip
ringlogger: hook into global panic writer
This is a grotesque hack, and hopefully upstream Go will provide a nicer way of doing this, but already it seems quite adept at catching panics. See https://github.com/golang/go/issues/42888 for more info. This requires us to rewrite the ringlogger path to avoid all allocations. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'go-patches/0014-runtime-make-write-into-function-pointer.patch')
-rw-r--r--go-patches/0014-runtime-make-write-into-function-pointer.patch32
1 files changed, 32 insertions, 0 deletions
diff --git a/go-patches/0014-runtime-make-write-into-function-pointer.patch b/go-patches/0014-runtime-make-write-into-function-pointer.patch
new file mode 100644
index 00000000..1618f02e
--- /dev/null
+++ b/go-patches/0014-runtime-make-write-into-function-pointer.patch
@@ -0,0 +1,32 @@
+From d7b6f2bfcee5787d9055f5d7ec92c74e258e8fab Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Thu, 3 Dec 2020 13:29:58 +0100
+Subject: [PATCH 14/14] runtime: make write into function pointer
+
+Change-Id: I77a32ff7e1494324e8cc38e792e007f86d32672d
+---
+ src/runtime/time_nofake.go | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/runtime/time_nofake.go b/src/runtime/time_nofake.go
+index 1912a94e87..0564448b2e 100644
+--- a/src/runtime/time_nofake.go
++++ b/src/runtime/time_nofake.go
+@@ -23,9 +23,14 @@ func walltime() (sec int64, nsec int32) {
+ return walltime1()
+ }
+
++var overrideWrite func(fd uintptr, p unsafe.Pointer, n int32) int32
++
+ // write must be nosplit on Windows (see write1)
+ //
+ //go:nosplit
+ func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
++ if overrideWrite != nil {
++ return overrideWrite(fd, noescape(p), n)
++ }
+ return write1(fd, p, n)
+ }
+--
+2.29.2
+