panic: runtime error: invalid memory address or nil pointer dereference

Bug #1841105 reported by Felipe Reyes
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Achilleas Anagnostopoulos

Bug Description

openstack.yaml -> http://paste.ubuntu.com/p/3PKTJXSzcR/
neutron-gateway.yaml -> http://paste.ubuntu.com/p/nbbZtCvghC/

$ snap info juju
...
installed: 2.7-beta1+develop-0f9f607 (8807) 75MB classic
$ juju --version
2.7-beta1-disco-amd64
$ juju deploy ./b/lp1680531/openstack.yaml --overlay ./b/lp1680531/o/neutron-gateway.yaml

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x8e5b0c]

goroutine 1 [running]:
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200, 0x0, 0x0, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:185 +0xbc
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitFieldsInMap(0xc420241200, 0x2bc5ca0, 0xc420974900, 0x15, 0x15)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:212 +0x1ae
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200, 0x2bc5ca0, 0xc420974900, 0x2bc5ca0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:189 +0x1dc
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.VerifyNoOverlayFieldsPresent.func1(0xc420241200, 0x3135680, 0xc42095d450, 0x199, 0x36f3200, 0x3135680, 0x1)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:127 +0x2c6
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200, 0x299d5c0, 0xc42095d450, 0x299d5c0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:187 +0x12e
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitFieldsInMap(0xc420241200, 0x2bb92e0, 0xc420974750, 0x15, 0x15)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:212 +0x1ae
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200, 0x2bb92e0, 0xc420974750, 0x2bb92e0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:189 +0x1dc
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.VerifyNoOverlayFieldsPresent.func1(0xc420241200, 0x3094da0, 0xc42010e780, 0x199, 0x36f3200, 0x3094da0, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:127 +0x2c6
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200, 0x2f23d40, 0xc42010e780, 0x8)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:187 +0x12e
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.VerifyNoOverlayFieldsPresent(0xc42010e780, 0xc4201b92d8, 0x1)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:142 +0x16b
github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.ReadAndMergeBundleData(0xc4202411a0, 0x2, 0x2, 0x1, 0x2, 0xc4202411a0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:422 +0x300
github.com/juju/juju/cmd/juju/application.composeAndVerifyBundle(0x3684a60, 0xc4209750b0, 0xc4205e79e0, 0x1, 0x1, 0x0, 0x7, 0xc420d13601)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/application/bundle.go:134 +0x25d
github.com/juju/juju/cmd/juju/application.(*DeployCommand).deployBundle(0xc4204182c0, 0xc4202b3040, 0x0, 0x3684a60, 0xc4209750b0, 0x0, 0x0, 0x0, 0xc4205e79e0, 0x1, ...)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/application/deploy.go:897 +0x397
github.com/juju/juju/cmd/juju/application.(*DeployCommand).maybeReadLocalBundle.func1(0xc4202b3040, 0x3701f20, 0xc4202a82a0, 0xc420240220, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/application/deploy.go:1363 +0x195
github.com/juju/juju/cmd/juju/application.(*DeployCommand).Run(0xc4204182c0, 0xc4202b3040, 0x0, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/application/deploy.go:1223 +0x49a
github.com/juju/juju/cmd/modelcmd.(*modelCommandWrapper).Run(0xc4203897a0, 0xc4202b3040, 0xc4203897a0, 0xc420975c50)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/modelcmd/modelcommand.go:606 +0x11c
github.com/juju/juju/cmd/modelcmd.(*baseCommandWrapper).Run(0xc420222330, 0xc4202b3040, 0x0, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/modelcmd/base.go:471 +0xab
github.com/juju/juju/vendor/github.com/juju/cmd.(*SuperCommand).Run(0xc42022c8c0, 0xc4202b3040, 0xc4202b3040, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/github.com/juju/cmd/supercommand.go:516 +0x2cc
github.com/juju/juju/vendor/github.com/juju/cmd.Main(0x36a3020, 0xc42022c8c0, 0xc4202b3040, 0xc4200e8100, 0x4, 0x4, 0x2de89e0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/vendor/github.com/juju/cmd/cmd.go:379 +0x2d9
github.com/juju/juju/cmd/juju/commands.main.Run(0x3366618, 0xc4200e80f0, 0x5, 0x5, 0x0)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/commands/main.go:143 +0x1af
github.com/juju/juju/cmd/juju/commands.Main(0xc4200e80f0, 0x5, 0x5, 0xc4200d4120)
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/commands/main.go:89 +0x4b
main.main()
 /build/juju/parts/juju/go/src/github.com/juju/juju/cmd/juju/main.go:37 +0x8c

Revision history for this message
Felipe Reyes (freyes) wrote :

downgrading the client to the one in the candidate channel make things work again.

Revision history for this message
Tim McNamara (tim-clicks) wrote : Re: [Bug 1841105] [NEW] panic: runtime error: invalid memory address or nil pointer dereference
Download full text (12.2 KiB)

Thanks for reporting this issue Filipe. Could you please switch the channel
to 2.6/stable and let us know if it's also an issue there?

On Fri, 23 Aug 2019 at 08:20, Felipe Reyes <email address hidden>
wrote:

> Public bug reported:
>
>
> openstack.yaml -> http://paste.ubuntu.com/p/3PKTJXSzcR/
> neutron-gateway.yaml -> http://paste.ubuntu.com/p/nbbZtCvghC/
>
> $ snap info juju
> ...
> installed: 2.7-beta1+develop-0f9f607 (8807) 75MB classic
> $ juju --version
> 2.7-beta1-disco-amd64
> $ juju deploy ./b/lp1680531/openstack.yaml --overlay
> ./b/lp1680531/o/neutron-gateway.yaml
>
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x8e5b0c]
>
> goroutine 1 [running]:
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200,
> 0x0, 0x0, 0x0)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:185 +0xbc
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitFieldsInMap(0xc420241200,
> 0x2bc5ca0, 0xc420974900, 0x15, 0x15)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:212 +0x1ae
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200,
> 0x2bc5ca0, 0xc420974900, 0x2bc5ca0)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:189 +0x1dc
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.VerifyNoOverlayFieldsPresent.func1(0xc420241200,
> 0x3135680, 0xc42095d450, 0x199, 0x36f3200, 0x3135680, 0x1)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:127 +0x2c6
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200,
> 0x299d5c0, 0xc42095d450, 0x299d5c0)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:187 +0x12e
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitFieldsInMap(0xc420241200,
> 0x2bb92e0, 0xc420974750, 0x15, 0x15)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:212 +0x1ae
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200,
> 0x2bb92e0, 0xc420974750, 0x2bb92e0)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:189 +0x1dc
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.VerifyNoOverlayFieldsPresent.func1(0xc420241200,
> 0x3094da0, 0xc42010e780, 0x199, 0x36f3200, 0x3094da0, 0x0)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:127 +0x2c6
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.visitField(0xc420241200,
> 0x2f23d40, 0xc42010e780, 0x8)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm.v6/overlay.go:187 +0x12e
>
> github.com/juju/juju/vendor/gopkg.in/juju/charm%2ev6.VerifyNoOverlayFieldsPresent(0xc42010e780,
> 0xc4201b92d8, 0x1)
> /build/juju/parts/juju/go/src/
> github.com/juju/juju/vendor/gopkg.in/juju/charm...

Revision history for this message
Felipe Reyes (freyes) wrote :

On Thu, 2019-08-22 at 20:37 +0000, Tim McNamara wrote:
> Thanks for reporting this issue Filipe. Could you please switch the
> channel
> to 2.6/stable and let us know if it's also an issue there?

with 2.6.6. there are no errors.

Revision history for this message
John A Meinel (jameinel) wrote :

The code in question is:
// visitField invokes ctx.structVisitor(val) if v is a struct and returns back
// the visitor's result. On the other hand, if val is a slice or a map,
// visitField invoke specialized functions that support iterating such types.
func visitField(ctx *visitorContext, val interface{}) bool {
        typ := reflect.TypeOf(val)
        v := reflect.ValueOf(val)

        // De-reference pointers
        if v.Kind() == reflect.Ptr {
                v = v.Elem()
                if v.Kind() == reflect.Invalid {
                        return false
                }
                typ = v.Type()
        }

        switch typ.Kind() {
        case reflect.Struct:
                return ctx.structVisitor(ctx, v, typ)
        case reflect.Map:
                return visitFieldsInMap(ctx, v)
        case reflect.Slice:
                return visitFieldsInSlice(ctx, v)
        }

        // v is not a struct or something we can iterate to reach a struct
        return false
}

But the docs:
https://golang.org/pkg/reflect/#TypeOf

say that reflect.TypeOf(nil) => nil, thus the later call to typ.Kind() is an invalid call.

I don't know what value in the bundle would point to nil, but regardless we can have code that is defensive against nil values.

Changed in juju:
assignee: nobody → Achilleas Anagnostopoulos (achilleasa)
importance: Undecided → High
status: New → Triaged
Changed in juju:
status: Triaged → In Progress
Revision history for this message
Achilleas Anagnostopoulos (achilleasa) wrote :

The attached base bundle defines the following set of variables:

# Variables
debug: &debug True
verbose: &verbose True
openstack_origin: &openstack_origin cloud:bionic-rocky
source: &source cloud:bionic-rocky
num_compute_units: &num_compute_units 1

ssl_ca: &ssl_ca
ssl_cert: &ssl_cert
ssl_key: &ssl_key

The ssl_* ones (which are defined to null in the above snippet) are referenced in the nova-cloud-controller app from the base bundle:

 nova-cloud-controller:
    num_units: 1
    charm: cs:~openstack-charmers-next/nova-cloud-controller
    constraints: mem=2G
    options:
      debug: *debug
      verbose: *verbose
      network-manager: Neutron
      openstack-origin: *openstack_origin
      ssl_ca: *ssl_ca
      ssl_cert: *ssl_cert
      ssl_key: *ssl_key

This causes a nil value to be passed into "visitField" which triggers the panic. Adding a check for nil values in the top of that function resolves the issue. I will push a PR with a fix.

Revision history for this message
Achilleas Anagnostopoulos (achilleasa) wrote :

PR https://github.com/juju/juju/pull/10565 includes a fix for the develop branch. Note, this issue does not affect the 2.6 line as this particular codepath is only used by the develop branch.

Revision history for this message
John A Meinel (jameinel) wrote :

Marking this fix released as it should be picked up in the next Edge build.

Changed in juju:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.