element-hq / element-hq/dendrite

dendrite-demo-yggdrasil. Invalid memory address or nil pointer dereference

Open
#3,193 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 [**@ri-gilfanov**](https://github.com/ri-gilfanov) at .*

### Background information
* Commit: 11fd2f019bb6325155c2fa825b82c1fbef07b300
* Database: PostgreSQL 14
* Manual build
* Go v1.20.3
* OS: Linux Mint 21.2 (based on Ubuntu 22.04)

### Description
Running:
```
cd /opt/dendrite
./bin/dendrite-demo-yggdrasil -config dendrite.yaml
```
Output:
```
INFO[2023-08-30T14:17:14.529017168Z] Dendrite version 0.13.2+11fd2f0
INFO[2023-08-30T14:17:14.531194306Z] TCP listener started on [::]:44685
INFO[2023-08-30T14:17:14.531606986Z] Public key: ae9046f7e60313d90e7b5d65c5addd4f0f887f40dc1b426c620f94249f2235dc
INFO[2023-08-30T14:17:14.533415082Z] TLS listener started on [fe80::5abb:e497:e8f6:e502%enp3s0]:43135
DEBU[2023-08-30T14:17:14.536699872Z] Setting DB connection limits conn_max_lifetime=-1s data_source_name="postgresql://127.0.0.1:5432/dendrite-yggdrasil?sslmode=disable" max_idle_conns=5 max_open_conns=90
INFO[2023-08-30T14:17:14.537723780Z] Connected inbound TLS: 224:f743:b01d:7e01:ceaa:8ff7:8291:accc@[fe80::5abb:e497:e8f6:e502%enp3s0]:49381, source [fe80::5abb:e497:e8f6:e502%enp3s0]:43135
INFO[2023-08-30T14:17:14.590434044Z] Starting nats-server component=jetstream
INFO[2023-08-30T14:17:14.590482411Z] Version: 2.9.19 component=jetstream
INFO[2023-08-30T14:17:14.590526983Z] Git: [not set] component=jetstream
INFO[2023-08-30T14:17:14.590564854Z] Name: monolith component=jetstream
INFO[2023-08-30T14:17:14.590601662Z] Node: 2VDOOQDB component=jetstream
INFO[2023-08-30T14:17:14.590645182Z] ID: NAQVNJ7U6MJE44ANIV3BRG2FOTG53YA23OESP5CK57AWIZZIWYYGDNA7 component=jetstream
WARN[2023-08-30T14:17:14.590696912Z] Maximum payloads over 8.00 MB are generally discouraged and could lead to poor performance component=jetstream
INFO[2023-08-30T14:17:14.590812319Z] Starting JetStream component=jetstream
INFO[2023-08-30T14:17:14.591387993Z] _ ___ _____ ___ _____ ___ ___ _ __ __ component=jetstream
INFO[2023-08-30T14:17:14.591428535Z] _ | | __|_ _/ __|_ _| _ \ __| /_\ | \/ | component=jetstream
INFO[2023-08-30T14:17:14.591461428Z] | || | _| | | \__ \ | | | / _| / _ \| |\/| | component=jetstream
INFO[2023-08-30T14:17:14.591507591Z] \__/|___| |_| |___/ |_| |_|_\___/_/ \_\_| |_| component=jetstream
INFO[2023-08-30T14:17:14.591645318Z] component=jetstream
INFO[2023-08-30T14:17:14.591682846Z] https://docs.nats.io/jetstream component=jetstream
INFO[2023-08-30T14:17:14.591744095Z] component=jetstream
INFO[2023-08-30T14:17:14.591812954Z] ---------------- JETSTREAM ---------------- component=jetstream
INFO[2023-08-30T14:17:14.591949492Z] Max Memory: 11.63 GB component=jetstream
INFO[2023-08-30T14:17:14.592140819Z] Max Storage: 33.01 GB component=jetstream
INFO[2023-08-30T14:17:14.592408239Z] Store Directory: "jetstream" component=jetstream
INFO[2023-08-30T14:17:14.592447028Z] ------------------------------------------- component=jetstream
INFO[2023-08-30T14:17:14.593007534Z] Starting restore for stream '$G > DendriteInputDeviceListUpdate' component=jetstream
INFO[2023-08-30T14:17:14.593584815Z] Restored 0 messages for stream '$G > DendriteInputDeviceListUpdate' component=jetstream
INFO[2023-08-30T14:17:14.594098125Z] Starting restore for stream '$G > DendriteInputRoomEvent' component=jetstream
INFO[2023-08-30T14:17:14.594742457Z] Restored 0 messages for stream '$G > DendriteInputRoomEvent' component=jetstream
INFO[2023-08-30T14:17:14.594902885Z] Starting restore for stream '$G > DendriteInputSigningKeyUpdate' component=jetstream
INFO[2023-08-30T14:17:14.595379842Z] Restored 0 messages for stream '$G > DendriteInputSigningKeyUpdate' component=jetstream
INFO[2023-08-30T14:17:14.595529140Z] Starting restore for stream '$G > DendriteOutputClientData' component=jetstream
INFO[2023-08-30T14:17:14.595986004Z] Restored 0 messages for stream '$G > DendriteOutputClientData' component=jetstream
INFO[2023-08-30T14:17:14.596146336Z] Starting restore for stream '$G > DendriteOutputKeyChangeEvent' component=jetstream
INFO[2023-08-30T14:17:14.596637297Z] Restored 0 messages for stream '$G > DendriteOutputKeyChangeEvent' component=jetstream
INFO[2023-08-30T14:17:14.596804604Z] Starting restore for stream '$G > DendriteOutputNotificationData' component=jetstream
INFO[2023-08-30T14:17:14.597279415Z] Restored 0 messages for stream '$G > DendriteOutputNotificationData' component=jetstream
INFO[2023-08-30T14:17:14.597441105Z] Starting restore for stream '$G > DendriteOutputReceiptEvent' component=jetstream
INFO[2023-08-30T14:17:14.597968539Z] Restored 0 messages for stream '$G > DendriteOutputReceiptEvent' component=jetstream
INFO[2023-08-30T14:17:14.598119644Z] Starting restore for stream '$G > DendriteOutputRoomEvent' component=jetstream
INFO[2023-08-30T14:17:14.598608793Z] Restored 0 messages for stream '$G > DendriteOutputRoomEvent' component=jetstream
INFO[2023-08-30T14:17:14.598765122Z] Starting restore for stream '$G > DendriteOutputSendToDeviceEvent' component=jetstream
INFO[2023-08-30T14:17:14.599212855Z] Restored 0 messages for stream '$G > DendriteOutputSendToDeviceEvent' component=jetstream
INFO[2023-08-30T14:17:14.599469762Z] Server is ready component=jetstream
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xfa19bc]

goroutine 1 [running]:
github.com/matrix-org/dendrite/roomserver/internal/query.(*Queryer).QueryLeftUsers(...)
/opt/dendrite/roomserver/internal/query/query.go:900
github.com/matrix-org/dendrite/userapi/internal.(*DeviceListUpdater).CleanUp(0xc00366ae60)
/opt/dendrite/userapi/internal/device_list_update.go:205 +0x163
github.com/matrix-org/dendrite/userapi.NewInternalAPI(0xc000514230, 0xc000289800, 0xc000508001?, 0x40?, {0x7f6b85e16620?, 0xc00369c000}, {0x7f6b85e16680?, 0xc000142b40})
/opt/dendrite/userapi/userapi.go:105 +0xd05
main.main()
/opt/dendrite/cmd/dendrite-demo-yggdrasil/main.go:216 +0x1529
```

### Steps to reproduce
- install and configuring Yggdrasil
- install Go 1.20 and change alternatives for /usr/bin/go
- clone Dendrite repo
- build binary files
- copy dendrite-sample.yaml as dendrite.yaml
- change a database connection string in dendrite.yaml
- running

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the crash with cmd/dendrite-demo-yggdrasil/main.go and the supplied PostgreSQL setup. Read roomserver/internal/query/query.go:900 and userapi/internal/device_list_update.go:205, following the call from userapi/userapi.go:105. Done means startup completes without the nil pointer dereference and the affected cleanup path is covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.