From 764d886ee8a336948297af40d348807d9b198421 Mon Sep 17 00:00:00 2001 From: David Florness Date: Sat, 1 Jan 2022 18:17:37 -0600 Subject: [PATCH] Use fork of mautrix-go with bugfix We're occasionally hitting the following error: panic: runtime error: slice bounds out of range [:208] with capacity 90 [recovered] panic: runtime error: slice bounds out of range [:208] with capacity 90 [recovered] panic: (*logrus.Entry) (0xbef2e0,0xc0000d2070) goroutine 1 [running]: github.com/sirupsen/logrus.(*Entry).log(0xc0001b62a0, 0x0, 0xc000464000, 0xf8f) /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:259 +0x2e2 github.com/sirupsen/logrus.(*Entry).Log(0xc0001b62a0, 0x0, 0xc0004383f0, 0x1, 0x1) /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:293 +0x86 github.com/sirupsen/logrus.(*Entry).Logf(0xc0001b62a0, 0xc000000000, 0xc0d38a, 0x1d, 0xc0004384a8, 0x2, 0x2) /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:338 +0xe2 github.com/sirupsen/logrus.(*Logger).Logf(0xc0000d2e00, 0x0, 0xc0d38a, 0x1d, 0xc0004384a8, 0x2, 0x2) /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:151 +0x94 github.com/sirupsen/logrus.(*Logger).Panicf(...) /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:192 github.com/sirupsen/logrus.Panicf(...) /home/matrix/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/exported.go:219 tallyard.xyz/ui.RoomTUI.func1(0xc000308130) /home/matrix/src/ui/tui.go:189 +0xe5 panic(0xba8da0, 0xc00033e980) /usr/lib/go/src/runtime/panic.go:679 +0x1b2 github.com/rivo/tview.(*Application).Run.func1(0xc000358000) /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/application.go:243 +0x82 panic(0xba8da0, 0xc00033e980) /usr/lib/go/src/runtime/panic.go:679 +0x1b2 maunium.net/go/mautrix/crypto/canonicaljson.RawJSONFromResult(...) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:274 maunium.net/go/mautrix/crypto/canonicaljson.sortJSONObject.func1(0x3, 0xc0003652c7, 0x9, 0xc0003652c8, 0x7, 0x0, 0xc7, 0x0, 0x0, 0x0, ...) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:113 +0x2b5 github.com/tidwall/gjson.Result.ForEach(0x5, 0xc0003652c6, 0x55, 0x0, 0x0, 0x0, 0xc6, 0x0, 0x0, 0x0, ...) /home/matrix/go/pkg/mod/github.com/tidwall/gjson@v1.12.1/gjson.go:293 +0x33d maunium.net/go/mautrix/crypto/canonicaljson.sortJSONObject(0x5, 0xc0003652c6, 0x55, 0x0, 0x0, 0x0, 0xc6, 0x0, 0x0, 0x0, ...) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:110 +0xe4 maunium.net/go/mautrix/crypto/canonicaljson.sortJSONValue(0x5, 0xc0003652c6, 0x55, 0x0, 0x0, 0x0, 0xc6, 0x0, 0x0, 0x0, ...) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:62 +0x23b maunium.net/go/mautrix/crypto/canonicaljson.sortJSONObject(0x5, 0xc000365200, 0x11c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:136 +0x39d maunium.net/go/mautrix/crypto/canonicaljson.sortJSONValue(0x5, 0xc000365200, 0x11c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:62 +0x23b maunium.net/go/mautrix/crypto/canonicaljson.SortJSON(0xc000364fc0, 0x11c, 0x11c, 0xc0003650e0, 0x0, 0x11c, 0xc000364fc0, 0x11c, 0x11c) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:51 +0x1b1 maunium.net/go/mautrix/crypto/canonicaljson.CanonicalJSONAssumeValid(0xc000364fc0, 0x11c, 0x11c, 0x120, 0xc000364ea0, 0x11c) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:42 +0xe0 maunium.net/go/mautrix/crypto/canonicaljson.CanonicalJSON(0xc000364d80, 0x11c, 0x120, 0x11c, 0x120, 0x0, 0x0, 0x382a611eb390c) /home/matrix/go/pkg/mod/maunium.net/go/mautrix@v0.10.8/crypto/canonicaljson/json.go:35 +0x8e tallyard.xyz/election.CalculateCommitment(0xc0004396e8, 0x1, 0x1, 0x20, 0x20, 0x20, 0x20) /home/matrix/src/election/utils.go:42 +0x153 tallyard.xyz/election.(*Election).JoinElection(0xc0000a6f00, 0xc0000e4460, 0xc000064140, 0x0, 0x0) /home/matrix/src/election/voter.go:101 +0x24d tallyard.xyz/ui.RoomTUI.func4(0x0, 0xc05072, 0xf, 0xc10084, 0x21, 0xc000000000) /home/matrix/src/ui/tui.go:268 +0x32f github.com/rivo/tview.(*List).InputHandler.func1(0xc00027a180, 0xc0003081b0) /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/list.go:591 +0x278 github.com/rivo/tview.(*Box).WrapInputHandler.func1(0xc00027a180, 0xc0003081b0) /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/box.go:167 +0x5d github.com/rivo/tview.(*Application).Run(0xc000358000, 0x0, 0x0) /home/matrix/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211202162923-2a6de950f73b/application.go:335 +0x7db tallyard.xyz/ui.(*tallyardApplication).Run(...) /home/matrix/src/ui/tui.go:594 tallyard.xyz/ui.RoomTUI(0xc0002fe060, 0xc0000e4460, 0xc00025c010, 0xc0002fe000, 0xd02740, 0xc0000a0820, 0xc00025c010, 0x0, 0x0) /home/matrix/src/ui/tui.go:285 +0x479 main.main() /home/matrix/src/cmd/tallyard/main.go:110 +0x7fb My fork of mautrix-go at git.hnitbjorg.xyz has a patch that forgoes a gjson optimization to prevent this issue. See https://git.hnitbjorg.xyz/~edwargix/mautrix-go/commit/f4965a653a70 and https://github.com/mautrix/go/issues/52 for further details. --- go.mod | 2 ++ go.sum | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 1057c2f..ea8bbee 100644 --- a/go.mod +++ b/go.mod @@ -18,3 +18,5 @@ require ( golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect maunium.net/go/mautrix v0.10.8 ) + +replace maunium.net/go/mautrix => git.hnitbjorg.xyz/~edwargix/mautrix-go v0.0.0-20220102001019-f4965a653a70 diff --git a/go.sum b/go.sum index 6d86a66..2a9ce6a 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +git.hnitbjorg.xyz/~edwargix/mautrix-go v0.0.0-20220102001019-f4965a653a70 h1:A2wwnpfKFhYG0JeaOP6K5X1CwMhaSh8AvZWJswKpgfU= +git.hnitbjorg.xyz/~edwargix/mautrix-go v0.0.0-20220102001019-f4965a653a70/go.mod h1:k4Ng5oci83MEbqPL6KOjPdbU7f8v01KlMjR/zTQ+7mA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= @@ -133,6 +135,4 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= maunium.net/go/maulogger/v2 v2.3.1/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A= -maunium.net/go/mautrix v0.10.8 h1:h64yDl8fMPk3j/tnkb6c5itSo/LZ1QSKQ3ze5zyanUg= -maunium.net/go/mautrix v0.10.8/go.mod h1:k4Ng5oci83MEbqPL6KOjPdbU7f8v01KlMjR/zTQ+7mA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= -- 2.38.4