New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OlmMachine.ProcessSyncResponse panic #52
Comments
Hi, I am experiencing an issue that looks to be the same as what you're facing:
Here's the log message with actual newlines and tabs:
I've found that the following patch fixes the issue, though at the expense of removing an optimization for gjson: From f4965a653a70e66786665431442c607b54de73e4 Mon Sep 17 00:00:00 2001
From: David Florness <david@florness.com>
Date: Fri, 31 Dec 2021 14:19:28 -0600
Subject: [PATCH] Don't use gjson slice optimization
This is a workaround for https://github.com/mautrix/go/issues/52
---
crypto/canonicaljson/json.go | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/crypto/canonicaljson/json.go b/crypto/canonicaljson/json.go
index 8c12176..231d798 100644
--- a/crypto/canonicaljson/json.go
+++ b/crypto/canonicaljson/json.go
@@ -266,15 +266,7 @@ func readHexDigits(input []byte) uint32 {
// RawJSONFromResult extracts the raw JSON bytes pointed to by result.
// input must be the json bytes that were used to generate result
func RawJSONFromResult(result gjson.Result, input []byte) (RawJSON []byte) {
- // This is lifted from gjson README. Basically, result.Raw is a copy of
- // the bytes we want, but its more efficient to take a slice.
- // If Index is 0 then for some reason we can't extract it from the original
- // JSON bytes.
- if result.Index > 0 {
- RawJSON = input[result.Index : result.Index+len(result.Raw)]
- } else {
- RawJSON = []byte(result.Raw)
- }
+ RawJSON = []byte(result.Raw)
return
}
--
2.32.0
I unfortunately haven't yet been able to find a proper fix, but hopefully this can be used as a workaround in the short term? All the best. |
Also, although the output here was for mautrix-go 0.10.6, the issue is still happening in version 0.10.8 (the latest release). Unfortunately I didn't think to keep the logs for when I last hit the problem on mautrix-go 0.10.8. |
I can provide logs for 0.10.8 if anybody need them, but they are pretty same |
Looks like there's some sort of regression in gjson. I noticed while trying to update the version used in mautrix-go and reverted it back to the old version now. I'm not sure why you were using the wrong version though. |
Sorry for delay, the issue fixed with new mautrix-go release, thank you! |
Yeah this shouldn't have applied to us right? I'm not sure how v0.10.9 fixes the issue since there's no change in the gjson version from v0.10.8: v0.10.8...v0.10.9 |
The updated gjson version was my issue |
All mautrix-go releases have the correct gjson version, but both of your stacktraces had the wrong version. Using the correct gjson version (v1.10.2) will fix it |
Oh I see; I didn't even notice the Regardless, thanks for the help! |
In my case it was |
I submitted a bug report in gjson for this issue: tidwall/gjson#263 |
Fix here: #62 |
Hello,
I'm trying to develop a bot on top of mautrix-go and faced odd issue - OlmMachine.ProcessSyncResponse panics on
canonicaljson.RawJSONFromResult
. The issue reproduced on synapse 1.49.1, 1.49.2 and different matrix accounts (I created a new account just to be sure the issue is not caused by some kind of "state" saved into that account) and different mautrix-go versions (0.10.5, 0.10.7, 0.10.8).here log (level=trace) with stacktrace:
Please, help me to fix that
The text was updated successfully, but these errors were encountered: