evcc-io / evcc

Solar Charging ☀️🚘
https://evcc.io
MIT License
3.66k stars 682 forks source link

SIGSEGV: segmentation violation when activating mqtt #17067

Closed juergen-weber closed 3 weeks ago

juergen-weber commented 3 weeks ago

Describe the bug

evcc worked fine with version 0.131.0. Version 0.131.4 stops with a segmentation violation - even with a fresh clone (git clone https://github.com/evcc-io/evcc). Issue seems to be related to the mqtt module. With mqtt being disabled, evcc starts up. Compiled on: EL9 5.14.0-427.42.1.el9_4.x86_64 go version go1.23.2 linux/amd64 node: '22.10.0'

Steps to reproduce

  1. git clone https://github.com/evcc-io/evcc
  2. make
  3. ./evcc
  4. ...

Configuration details

# open evcc at http://evcc.local:7070
network:
  schema: http
  host: evcc.local # .local suffix announces the hostname on MDNS
  port: 7070

# database configuration for persisting charge sessions and settings
database:
  type: sqlite
  dsn: /config/evcc/evcc.db

log: debug
levels:
  cache: error

# unique installation id
plant: e42e385b6fa330f5b9e09faa40aa547603d5904eac8ebda2d4ebb97f38c70530

interval: 30s # control cycle interval

# for documentation see https://docs.evcc.io/docs/devices/meters
meters:
  - name: grid
    type: custom
    power: #Power # default value, optionally override # Leistung (W)
      source: mqtt
      topic: meter/totalpower
      timeout: 120s
      scale: 1
    energy: #Sum # default value, optionally override
      source: mqtt
      topic: meter/energyimport
      timeout: 180s
      scale: 1
    currents:
      - source: mqtt
        topic: adl400/current_l1
        timeout: 120s
        scale: 0.01
      - source: mqtt
        topic: adl400/current_l2
        timeout: 120s
        scale: 0.01
      - source: mqtt
        topic: adl400/current_l3
        timeout: 120s
        scale: 0.01

  - name: pv # Leistung PV
    type: custom
    power:
      source: mqtt
      topic: sdm630/totalpower
      timeout: 40s
    energy: #Sum # default value, optionally override
      source: mqtt
      topic: sdm630/energyproduced
      timeout: 120s
      scale: 1

  - name: battery
    type: template
    template: sax
    modbus: tcpip
    id: 64
    host: 10.0.0.157
    port: 502

site:
  title: Mein Zuhause
  meters:
    battery:
    - battery

# mqtt message broker
mqtt:
  broker: 10.0.0.21:1883
  topic: evcc # root topic for publishing, set empty to disable
  #user: 
  #password:

Log details

Nov  4 08:35:40 nuci3 systemd[1]: Started evcc.
Nov  4 08:35:40 nuci3 evcc[7647]: [main  ] INFO 2024/11/04 08:35:40 evcc 0.131.4 (b00c03cd)
Nov  4 08:35:40 nuci3 evcc[7647]: [main  ] INFO 2024/11/04 08:35:40 using config file: /etc/evcc/evcc.yaml
Nov  4 08:35:40 nuci3 evcc[7647]: [db    ] INFO 2024/11/04 08:35:40 using sqlite database: /config/evcc/evcc.db
Nov  4 08:35:40 nuci3 evcc[7647]: [mqtt  ] INFO 2024/11/04 08:35:40 connecting evcc-1058436953 at tcp://10.0.0.21:1883
Nov  4 08:35:40 nuci3 evcc[7647]: [mqtt  ] DEBUG 2024/11/04 08:35:40 tcp://10.0.0.21:1883 connected
Nov  4 08:35:40 nuci3 evcc[7647]: [main  ] INFO 2024/11/04 08:35:40 listening at :7070
Nov  4 08:35:40 nuci3 evcc[7647]: panic: runtime error: invalid memory address or nil pointer dereference
Nov  4 08:35:40 nuci3 evcc[7647]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x12fb3f1]
Nov  4 08:35:40 nuci3 evcc[7647]: goroutine 22 [running]:
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/provider.(*Mqtt).WithScale(...)
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/provider/mqtt.go:93
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/provider.NewMqttFromConfig({0x38dfb40, 0xc001bc2480}, 0xc001bc24e0)
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/provider/mqtt.go:52 +0x1f1
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/provider.provider[...]({0x2f71981, 0x5}, {0x38dfb40, 0xc001bc2480}, {{0xc000ab29d0, 0x2a46860?}, 0xc001bc24e0?})
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/provider/config.go:58 +0xaf
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/provider.NewFloatGetterFromConfig({0x38dfb40?, 0xc001bc2480?}, {{0xc000ab29d0?, 0xc001b84b00?}, 0xc001bc24e0?})
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/provider/config.go:83 +0x49
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/meter.BuildMeasurements({0x38dfb40, 0xc001bc2480}, 0x2a46860?, 0xc00050caf8)
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/meter/helper.go:16 +0x4b
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/meter.NewConfigurableFromConfig({0x38dfb40, 0xc001bc2480}, 0xc000b7f2f0)
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/meter/meter.go:45 +0xbb
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/meter.NewFromConfig({0x38dfb40, 0xc001bc2480}, {0xc000ab2984, 0x6}, 0xc000b7f2f0)
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/meter/config.go:26 +0xa9
Nov  4 08:35:40 nuci3 evcc[7647]: github.com/evcc-io/evcc/cmd.configureMeters.func1()
Nov  4 08:35:40 nuci3 evcc[7647]: #011github.com/evcc-io/evcc/cmd/setup.go:225 +0x71
Nov  4 08:35:40 nuci3 evcc[7647]: golang.org/x/sync/errgroup.(*Group).Go.func1()
Nov  4 08:35:40 nuci3 evcc[7647]: #011golang.org/x/sync@v0.8.0/errgroup/errgroup.go:78 +0x50
Nov  4 08:35:40 nuci3 evcc[7647]: created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
Nov  4 08:35:40 nuci3 evcc[7647]: #011golang.org/x/sync@v0.8.0/errgroup/errgroup.go:75 +0x96
Nov  4 08:35:40 nuci3 systemd[1]: evcc.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Nov  4 08:35:40 nuci3 systemd[1]: evcc.service: Failed with result 'exit-code'.
Nov  4 08:35:45 nuci3 systemd[1]: evcc.service: Scheduled restart job, restart counter is at 262.
Nov  4 08:35:45 nuci3 systemd[1]: Stopped evcc.

What type of operating system are you running?

Linux

Nightly build

Version

0.131.4

andig commented 3 weeks ago

Fixed in https://github.com/evcc-io/evcc/commit/675036a9d77e8d780c17a43ac07c7e7da66dba3e