element-hq / element-hq/dendrite

Runtime panick when logging in via Element X

Open
#3,346 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
965
Forks
101
PR merge metrics
No merged PRs in 30d

Description

*This issue was originally created by [**@pat-s**](https://github.com/pat-s) at .*

### Background information

- **Dendrite version or git SHA**: 0.13.6
- **SQLite3 or Postgres?**: Postgres
- **Running in Docker?**: Yes
- **`go version`**:
- **Client used (if applicable)**: Element X

### Description

- **What** is the problem: Runtime panick during Element X connection
- **Who** is affected:
- **How** is this bug manifesting:
- **When** did this first appear:

Dendrite is configured with `slidingsync` and returns the `"org.matrix.msc3575.proxy"` in `.well-known/matrix/client`.

Login via Element Web succeeds.

### Steps to reproduce

Element X iOS: 1.5.12
Slidingsync: v0.99.15

The process runs for 5-10 seconds and then aborts with the below log in Dendrite:

Logs:

```
time="2024-03-22T20:29:54.425449714Z" level=error msg="Request panicked!\ngoroutine 507 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x64\ngithub.com/matrix-org/dendrite/internal/httputil.MakeExternalAPI.MakeJSONAPI.Protect.func3.1()\n\tgithub.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:98 +0xf8\npanic({0x112bae0?, 0x218c010?})\n\truntime/panic.go:914 +0x218\ngithub.com/matrix-org/dendrite/clientapi/auth.(*LoginTypePassword).Login(0x40045474c0, {0x1628188, 0x400454f950}, {0x1142a80?, 0x40041760a0})\n\tgithub.com/matrix-org/dendrite/clientapi/auth/password.go:128 +0x4c8\ngithub.com/matrix-org/dendrite/clientapi/auth.(*LoginTypePassword).LoginFromJSON(0x4004543e00?, {0x1628188, 0x400454f950}, {0x4004543e00, 0xa1, 0x200})\n\tgithub.com/matrix-org/dendrite/clientapi/auth/password.go:54 +0x7c\ngithub.com/matrix-org/dendrite/clientapi/auth.LoginFromJSONReader(0x400376db00, {0xffff5f4401b0?, 0x40035bd200}, {0xffff5f49a1b8?, 0x40035bd200}, 0x4000509050)\n\tgithub.com/matrix-org/dendrite/clientapi/auth/login.go:94 +0x548\ngithub.com/matrix-org/dendrite/clientapi/routing.Login(0x400376db00, {0xffff5f440008?, 0x40035bd200}, 0x4000509050)\n\tgithub.com/matrix-org/dendrite/clientapi/routing/login.go:62 +0x170\ngithub.com/matrix-org/dendrite/clientapi/routing.Setup.func56(0x0?)\n\tgithub.com/matrix-org/dendrite/clientapi/routing/routing.go:730 +0x80\ngithub.com/matrix-org/util.(*jsonRequestHandlerWrapper).OnIncomingRequest(0x400376da00?, 0x1ea54?)\n\tgithub.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:79 +0x28\ngithub.com/matrix-org/dendrite/internal/httputil.MakeExternalAPI.MakeJSONAPI.func2({0x1625420, 0x400414e380}, 0x400376da00?)\n\tgithub.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:141 +0xbc\ngithub.com/matrix-org/dendrite/internal/httputil.MakeExternalAPI.MakeJSONAPI.Protect.func3({0x1625420?, 0x400414e380?}, 0x1330467?)\n\tgithub.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:103 +0x64\nnet/http.HandlerFunc.ServeHTTP(...)\n\tnet/http/server.go:2136\ngithub.com/matrix-org/dendrite/internal/httputil.MakeExternalAPI.func1({0x1625420?, 0x400414e380?}, 0x400376d900)\n\tgithub.com/matrix-org/dendrite/internal/httputil/httpapi.go:193 +0x314\nnet/http.HandlerFunc.ServeHTTP(0x400376d800?, {0x1625420?, 0x400414e380?}, 0xffffa644d108?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/gorilla/mux.(*Router).ServeHTTP(0x40001f8780, {0x1625420, 0x400414e380}, 0x400376d700)\n\tgithub.com/gorilla/mux@v1.8.0/mux.go:210 +0x194\ngithub.com/gorilla/mux.(*Router).ServeHTTP(0x40035b9500, {0x1625420, 0x400414e380}, 0x400376d500)\n\tgithub.com/gorilla/mux@v1.8.0/mux.go:210 +0x194\nnet/http.serverHandler.ServeHTTP({0x1621f98?}, {0x1625420?, 0x400414e380?}, 0x6?)\n\tnet/http/server.go:2938 +0xbc\nnet/http.(*conn).serve(0x400455c990, {0x1628188, 0x4003dd90e0})\n\tnet/http/server.go:2009 +0x518\ncreated by net/http.(*Server).Serve in goroutine 277\n\tnet/http/server.go:3086 +0x4cc\n" context=missing panic="runtime error: invalid memory address or nil pointer dereference"
```

Contributor guide

Open the contributing guide

Research direction

Start in clientapi/auth/password.go at line 128, then trace the login request through login.go and clientapi/routing/login.go. Reproduce with Element X on iOS against the reported Postgres, Docker, and sliding sync setup, and use the stack trace to inspect the nil-pointer path. Done means the login request no longer panics and Element X can log in successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, ios, postgres
Domain
authentication, backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.