Skip to content
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

Invalid memory address or nil pointer dereference runtime error #494

Closed
MonicaisHer opened this issue Mar 28, 2023 · 0 comments · Fixed by #495
Closed

Invalid memory address or nil pointer dereference runtime error #494

MonicaisHer opened this issue Mar 28, 2023 · 0 comments · Fixed by #495
Labels
bug Something isn't working

Comments

@MonicaisHer
Copy link
Contributor

🐞 Bug Report

Affected Services [REQUIRED]

The issue is located in:
  • support-scheduler
  • support-notifications
  • core-data
  • core-command
  • core-metadata

Is this a regression?

Yes, the previous version in which this bug was not present was:

edgexfoundry_3.0.0-dev.108

Description and Minimal Reproduction [REQUIRED]

There is a runtime error caused by a nil pointer dereference or invalid memory address access while setting certain environment variables:

$ snap install edgexfoundry --edge
edgexfoundry (edge) 3.0.0-dev.114 from Canonical✓ installed
$ sudo snap set edgexfoundry apps.core-data.config.edgex-config-provider='none'
$ sudo snap set edgexfoundry apps.core-data.config.edgex-common-config=./config/core-common-config-bootstrapper/res/configuration.yaml
$ sudo snap set edgexfoundry apps.core-data.config.service-startupmsg='manual-snap-testing'
$ snap restart edgexfoundry.core-data

🔥 Exception or Error

$ journalctl -f | grep core-data
Mär 27 14:51:55 ubuntu systemd[1]: Started Service for snap application edgexfoundry.core-data.
Mär 27 14:51:55 ubuntu edgex-core-data.service-config-overrides.sh[34122]: sourcing /var/snap/edgexfoundry/4359/config/core-data/res/core-data.env
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473473087Z app=core-data source=secret.go:65 msg="Creating SecretClient"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473585204Z app=core-data source=variables.go:457 msg="Variables override of 'SecretStore/TokenFile' by environment variable: SECRETSTORE_TOKENFILE=/var/snap/edgexfoundry/4359/secrets/core-data/secrets-token.json"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473645868Z app=core-data source=secret.go:159 msg="SecretStore information created with 1 overrides applied"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473653455Z app=core-data source=secret.go:75 msg="Reading secret store configuration and authentication token"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473660562Z app=core-data source=secret.go:200 msg="load token from file"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473732885Z app=core-data source=secret.go:93 msg="Attempting to create secret client"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474765087Z app=core-data source=secret.go:104 msg="Created SecretClient"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474775605Z app=core-data source=secret.go:109 msg="SecretsFile not set, skipping seeding of service secrets."
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474787185Z app=core-data source=variables.go:457 msg="Variables override of 'Configuration Provider Information' by environment variable: EDGEX_CONFIG_PROVIDER=none"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474795573Z app=core-data source=variables.go:457 msg="Variables override of '-cc/--commonConfig' by environment variable: EDGEX_COMMON_CONFIG=./config/core-common-config-bootstrapper/res/configuration.yaml"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474801088Z app=core-data source=config.go:565 msg="Loading configuration file from ./config/core-common-config-bootstrapper/res/configuration.yaml"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.475239929Z app=core-data source=secrets.go:277 msg="kick off token renewal with interval: 30m0s"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: panic: runtime error: invalid memory address or nil pointer dereference
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x7553df]
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: goroutine 1 [running]:
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).buildPaths(0xc0004b0f38?, 0x5?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/environment/variables.go:236 +0x11f
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).buildPaths(0xc0004b10a8?, 0x5?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/environment/variables.go:243 +0x1d4
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).buildPaths(0x852dc0?, 0xc0004423e0?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/environment/variables.go:243 +0x1d4
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).OverrideConfigMapValues(0xc000012378, 0x61c?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/environment/variables.go:149 +0x3e
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).OverrideConfiguration(0xc0000b69a0?, {0x8ccd00, 0xc0003c5e00})
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/environment/variables.go:130 +0x14f
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/config.(*Processor).Process(0xc0000b69a0, {0x9132b7, 0x9}, {0x90f6dc, 0x5}, {0x912c27, 0x8}, {0x9ce3b8, 0xc0003c5e00}, {0x9ceea0, ...})
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/config/config.go:188 +0x765
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap.RunAndReturnWaitGroup({0x9cb2d0, 0xc0003eeaa0}, 0xc0003fb7b0, {0x9ce418?, 0xc00042a770}, {0x9132b7, 0x9}, {0x912c27, 0x8}, {0x9ce3b8, ...}, ...)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/bootstrap.go:126 +0x4ac
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap.Run({0x9cb2d0?, 0xc0003eeaa0?}, 0xc0003fb7b0, {0x9ce418?, 0xc00042a770?}, {0x9132b7?, 0x0?}, {0x912c27?, 0x0?}, {0x9ce3b8, ...}, ...)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/go-mod-bootstrap/[email protected]/bootstrap/bootstrap.go:215 +0x11d
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/edgex-go/internal/core/data.Main({0x9cb2d0, 0xc0003eeaa0}, 0x405391?, 0xc000001d40)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/edgex-go/internal/core/data/main.go:62 +0x705
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: main.main()
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]:         github.com/edgexfoundry/edgex-go/cmd/core-data/main.go:27 +0x89
Mär 27 14:51:55 ubuntu systemd[1]: snap.edgexfoundry.core-data.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mär 27 14:51:55 ubuntu systemd[1]: snap.edgexfoundry.core-data.service: Failed with result 'exit-code'.

🌍 Your Environment

Deployment Environment:
Ubuntu 22.04 LTS
EdgeX Version [REQUIRED]:

3.0.0-dev.114
Anything else relevant?
it's possible that the error is being caused by the item variable in the for loop. if item is a nil pointer, then attempting to access its Kind() method would result in a runtime error. To fix this issue, we can add a check to see if item is not nil before calling Kind() on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant