enbility / eebus-go

EEBUS protocol implementation in go
https://enbility.net
MIT License
52 stars 14 forks source link

Crash when removing an device entity which does not exist #49

Closed DerAndereAndi closed 1 year ago

DerAndereAndi commented 1 year ago

Source: https://github.com/evcc-io/evcc/discussions/6496

Stacktrace:

2023-02-27T15:10:54.854609155Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/events.go:78 +0xa5
2023-02-27T15:10:54.854559764Z | stdout | created by github.com/enbility/eebus-go/spine.(*events).Publish
2023-02-27T15:10:54.854499288Z | stdout | /go/pkg/mod/github.com/enbility/cemd@v0.1.6/emobility/events.go:39 +0x16a
2023-02-27T15:10:54.854416743Z | stdout | github.com/enbility/cemd/emobility.(*EMobilityImpl).HandleEvent(0xc000a6e100, {{0xc0006e67b0, 0x28}, 0x1, 0x2, 0xc001131bc0, 0x0, 0x0, {0x1ad6dc0, 0xc001430400}})
2023-02-27T15:10:54.854281886Z | stdout | goroutine 112049 [running]:
2023-02-27T15:10:54.854207103Z | stdout |  
2023-02-27T15:10:54.854066831Z | stdout | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf7374a]
2023-02-27T15:10:54.853794559Z | stdout | panic: runtime error: invalid memory address or nil pointer dereference
2023-02-27T15:10:54.846665204Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/ship/websocket.go:66 +0xca
2023-02-27T15:10:54.846618665Z | stdout | created by github.com/enbility/eebus-go/ship.(*websocketConnection).run
2023-02-27T15:10:54.846570440Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/ship/websocket.go:140 +0x102
2023-02-27T15:10:54.846521349Z | stdout | github.com/enbility/eebus-go/ship.(*websocketConnection).readShipPump(0xc001131740)
2023-02-27T15:10:54.846471682Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/ship/connection.go:174 +0xa2
2023-02-27T15:10:54.846420826Z | stdout | github.com/enbility/eebus-go/ship.(*ShipConnection).HandleIncomingShipMessage(0xc0009ec680, {0xc0004ba380, 0x2f1, 0x380})
2023-02-27T15:10:54.846371406Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/device_remote.go:75 +0xbd
2023-02-27T15:10:54.846318345Z | stdout | github.com/enbility/eebus-go/spine.(*DeviceRemoteImpl).HandleIncomingSpineMesssage(0xc001131bc0, {0xc000e50a00, 0x27d, 0x280})
2023-02-27T15:10:54.846257818Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/device_local.go:216 +0x442
2023-02-27T15:10:54.846128692Z | stdout | github.com/enbility/eebus-go/spine.(*DeviceLocalImpl).ProcessCmd(0xc000e55080?, {{0xc0012b7d00, 0xc000b5eed0, 0xc000b5ef00, 0x0, 0xc0010cb4d8, 0x0, 0xc0012b7d30, 0x0, 0x0}, ...}, ...)
2023-02-27T15:10:54.846076681Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/nodemanagement.go:62 +0x7ba
2023-02-27T15:10:54.846025120Z | stdout | github.com/enbility/eebus-go/spine.(*NodeManagementImpl).HandleMessage(0xc0009f63f0?, 0xc0012b7e00?)
2023-02-27T15:10:54.845913436Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/nodemanagement_defaileddiscovery.go:247 +0x14a
2023-02-27T15:10:54.845865887Z | stdout | github.com/enbility/eebus-go/spine.(*NodeManagementImpl).handleMsgDetailedDiscoveryData(0x0?, 0x0?, 0x0?)
2023-02-27T15:10:54.845813752Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/nodemanagement_defaileddiscovery.go:192 +0x2d0
2023-02-27T15:10:54.845761433Z | stdout | github.com/enbility/eebus-go/spine.(*NodeManagementImpl).processNotifyDetailedDiscoveryData(0xc000c68560, 0x0?, 0xc001430400)
2023-02-27T15:10:54.845694688Z | stdout | /go/pkg/mod/github.com/enbility/eebus-go@v0.1.6/spine/subscription_manager.go:137 +0xba
2023-02-27T15:10:54.845613393Z | stdout | github.com/enbility/eebus-go/spine.(*SubscriptionManagerImpl).RemoveSubscriptionsForEntity(0xc000c4f420, 0x0)
2023-02-27T15:10:54.845404577Z | stdout | goroutine 110999 [running]:
2023-02-27T15:10:54.845365051Z | stdout |  
2023-02-27T15:10:54.845267766Z | stdout | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xdf891a]
2023-02-27T15:10:54.844686583Z | stdout | panic: runtime error: invalid memory address or nil pointer dereference

It looks like the remote device sent a DetailedDiscovery message to remove a device entity, which does not exist.

DerAndereAndi commented 1 year ago

Fixed in https://github.com/enbility/eebus-go/commit/5abbdbaf7d0fc437edf4916c7ca207564e10310f