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

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

Closed
pkelleratwork opened this issue Dec 13, 2017 · 22 comments
Closed

Comments

@pkelleratwork
Copy link

version 1.6.0 (e4adfef)
macOS 10.13.2

kompose convert =

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

goroutine 1 [running]:
github.com/kubernetes/kompose/pkg/loader/compose.dockerComposeToKomposeMapping(0xc4205dc6c0, 0x20, 0xc42045d820, 0x1, 0x1, 0xc4200d35f0)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:323 +0x45b
github.com/kubernetes/kompose/pkg/loader/compose.parseV3(0xc4203686f0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x30, 0x27e2280)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:113 +0x22b
github.com/kubernetes/kompose/pkg/loader/compose.(*Compose).LoadFile(0x370a980, 0xc4203686f0, 0x1, 0x1, 0xc4200d3080, 0x0, 0x0, 0x9, 0x7)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/compose.go:186 +0x4d2
github.com/kubernetes/kompose/pkg/app.Convert(0x100000100, 0x0, 0x0, 0x0, 0x0, 0x28a1b28, 0x4, 0x0, 0x28b5b4d, 0x15, ...)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/pkg/app/app.go:227 +0x145
github.com/kubernetes/kompose/cmd.glob..func3(0x36d8660, 0x370a980, 0x0, 0x0)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/cmd/convert.go:95 +0x4d
github.com/kubernetes/kompose/vendor/github.com/spf13/cobra.(*Command).execute(0x36d8660, 0x370a980, 0x0, 0x0, 0x36d8660, 0x370a980)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/vendor/github.com/spf13/cobra/command.go:704 +0x2c6
github.com/kubernetes/kompose/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x36d8aa0, 0x36d8ee0, 0x2499880, 0x36d8be0)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/vendor/github.com/spf13/cobra/command.go:785 +0x30e
github.com/kubernetes/kompose/vendor/github.com/spf13/cobra.(*Command).Execute(0x36d8aa0, 0x0, 0xc420315f48)
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/vendor/github.com/spf13/cobra/command.go:738 +0x2b
github.com/kubernetes/kompose/cmd.Execute()
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/cmd/root.go:92 +0x31
main.main()
/home/wikus/dropbox/dev/go/src/github.com/kubernetes/kompose/main.go:22 +0x20

@cdrage
Copy link
Member

cdrage commented Dec 13, 2017

Okay, that is so odd that you're getting my folder...

/home/wikus/dropbox/dev/go/src/github.com

Can you post the full command you're using?

@pkelleratwork
Copy link
Author

ran from the directory containing the docker-compose.yml file i tried converting....

"my"-MacBook-Pro:azure$ kompose convert
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2220eeb]

goroutine 1 [running]:
github.com/kubernetes/kompose/pkg/loader/compose.dockerComposeToKomposeMapping(0xc4200aa780, 0x20, 0xc420428220, 0x1, 0x1, 0xc420143890)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:323 +0x45b
github.com/kubernetes/kompose/pkg/loader/compose.parseV3(0xc42058faf0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x30, 0x27e9f00)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:113 +0x22b
github.com/kubernetes/kompose/pkg/loader/compose.(*Compose).LoadFile(0x3723c40, 0xc42058faf0, 0x1, 0x1, 0xc420143320, 0x0, 0x0, 0x10, 0xf)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/pkg/loader/compose/compose.go:186 +0x4d2
github.com/kubernetes/kompose/pkg/app.Convert(0x100000100, 0x0, 0x0, 0x0, 0x0, 0x28a9a38, 0x4, 0x0, 0x28bda27, 0x15, ...)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/pkg/app/app.go:227 +0x145
github.com/kubernetes/kompose/cmd.glob..func3(0x36f1960, 0x3723c40, 0x0, 0x0)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/cmd/convert.go:95 +0x4d
github.com/kubernetes/kompose/vendor/github.com/spf13/cobra.(*Command).execute(0x36f1960, 0x3723c40, 0x0, 0x0, 0x36f1960, 0x3723c40)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/vendor/github.com/spf13/cobra/command.go:704 +0x2c6
github.com/kubernetes/kompose/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x36f1da0, 0x36f21e0, 0x249fa70, 0x36f1ee0)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/vendor/github.com/spf13/cobra/command.go:785 +0x30e
github.com/kubernetes/kompose/vendor/github.com/spf13/cobra.(*Command).Execute(0x36f1da0, 0x0, 0xc420227f48)
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/vendor/github.com/spf13/cobra/command.go:738 +0x2b
github.com/kubernetes/kompose/cmd.Execute()
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/src/github.com/kubernetes/kompose/cmd/root.go:92 +0x31
main.main()
/private/tmp/kompose-20171212-31628-9y6gll/kompose-1.6.0/main.go:22 +0x20

@cdrage
Copy link
Member

cdrage commented Dec 13, 2017

@pkelleratwork Ah, that's better!

Are you able to post the docker-compose.yaml file that you are using?

@pkelleratwork
Copy link
Author

sorry - cant post it here....

@pkelleratwork
Copy link
Author

its pretty standard, nothing wild. front end, back end, proxy in it.

@cdrage
Copy link
Member

cdrage commented Dec 13, 2017

One thing to check if if you've got any blank environment variables within it. That may be one of the reasons. For example, if you have:

env:
  - MYSECRETPASS

and echo $MYSECRETPASS is blank it may be erroring.

@pkelleratwork
Copy link
Author

confirmed no blank env variables. there are foo=${bar} using a .env file to populate, but nothing blank

echo $MYSECRETPASS is also blank

@cdrage
Copy link
Member

cdrage commented Dec 13, 2017

Without the docker-compose.yaml file I wouldn't be able to diagnose it :( Are you able to create I guess a "fake" docker-compose.yaml file with no revealing information so I can replicate it my end?

@pkelleratwork
Copy link
Author

pkelleratwork commented Dec 13, 2017

here you go... verified I get the same error with this "fake" on..

@pkelleratwork
Copy link
Author

fake docker compose.txt

@Code0x58
Copy link
Contributor

Code0x58 commented Dec 14, 2017

I found the same issue, here is a minimal working docker-compose.yml which will cause a segfault if you remove either of limits/reservations and convert with at either kompose 1.5.0 (999278f) and 1.6.0 (e4adfef) - untested on lower versions:

version: '3'
services:
  segfault-central:
    image: alpine
    deploy:
      resources:
        limits:
          cpus: '0.01'
          memory: 256M
        reservations:
          cpus: '0.01'
          memory: 128M

@cdrage
Copy link
Member

cdrage commented Dec 14, 2017

Hey @Code0x58 I was unable to replicate the issue with either your above docker-compose.yaml file or the modified one with limits / reservations removed.

version: '3'                                                                                                                                                                                                                                                                      
services:                                                                                                                                                                                                                                                                         
  segfault-central:                                                                                                                                                                                                                                                               
    image: alpine                                                                                                                                                                                                                                                                               

@cdrage
Copy link
Member

cdrage commented Dec 14, 2017

Hey @pkelleratwork so it looks like it's an issue with the v3 implentation.

Changing to version: 2 in your docker-compose.yaml file will fix it. I have a feeling it's about the environment variable implementation.

@pkelleratwork
Copy link
Author

thanks @cdrage - I'll give it a shot!

@cdrage
Copy link
Member

cdrage commented Dec 14, 2017

I found out where it's happening, https://github.com/kubernetes/kompose/blob/master/pkg/loader/compose/v3.go#L322

Now it's time to debug and see how to fix it.

Looks like it happens if there is a blank variable somewhere within the implementation.

@pkelleratwork
Copy link
Author

@cdrage - changed version to "2", it worked :)

-MacBook-Pro:kompose $ kompose convert
WARN The REPO variable is not set. Substituting a blank string.
WARN The IMAGE variable is not set. Substituting a blank string.
WARN The REPO variable is not set. Substituting a blank string.
WARN The IMAGE variable is not set. Substituting a blank string.
WARN The API variable is not set. Substituting a blank string.
WARN The HOST variable is not set. Substituting a blank string.
WARN The HOST variable is not set. Substituting a blank string.
WARN The REPO variable is not set. Substituting a blank string.
WARN The IMAGE variable is not set. Substituting a blank string.
WARN The ENV variable is not set. Substituting a blank string.
WARN Unsupported root level networks key - ignoring
WARN Unsupported networks key - ignoring
WARN Unsupported depends_on key - ignoring
WARN Volume mount on the host "./data/db" isn't supported - ignoring path on the host
WARN Volume mount on the host "./data/redis" isn't supported - ignoring path on the host
INFO Kubernetes file "api-service.yaml" created
INFO Kubernetes file "db-service.yaml" created
INFO Kubernetes file "proxy-service.yaml" created
INFO Kubernetes file "redis-service.yaml" created
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "api-deployment.yaml" created
INFO Kubernetes file "db-deployment.yaml" created
INFO Kubernetes file "db-claim0-persistentvolumeclaim.yaml" created
INFO Kubernetes file "proxy-deployment.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "redis-claim0-persistentvolumeclaim.yaml" created
INFO Kubernetes file "web-deployment.yaml" created

@Code0x58
Copy link
Contributor

Code0x58 commented Dec 14, 2017

Hey @cdrage, the file you pasted had both of them removed, with one of them removed it blows up for me:

version: '3'
services:
  segfault-central:
    image: alpine
    deploy:
      resources:
        limits:
          cpus: '0.01'
          memory: 256M

@gak
Copy link

gak commented Dec 26, 2017

I just got hit with the same issue (and fix) as @Code0x58 mentioned on #892 (comment).

v1.6.0 (e4adfef), macOs 10.13.1 (17B1003)

With a simple service:

version: '3'

services:
  nginx:
    image: nginx

These work:

    deploy:
      resources: {}
    deploy:
      resources:
        limits:
          cpus: '0.01'
          memory: 256M
        reservations:
          cpus: '0.01'
          memory: 128M

These don't work:

    deploy:
      resources:
        reservations: {}
    deploy:
      resources:
        reservations:
          cpus: '0.1'
          memory: 50M
    deploy:
      resources:
        limits: {}

An error, but not a SIGSEGV for this:

    deploy:
      resources:
        resources: {}
        limits: {}

@Code0x58
Copy link
Contributor

Code0x58 commented Dec 26, 2017

For the resources case that myself and @gak encountered, I believe the issue is caused by these two lines.

@pkelleratwork @cdrage after some cutting down it appears that the minimum way to reproduce the error is:

version: "3"
services:
  segfault-central:
    environment:
      - FOO_CONFIG

Similarly, stripping out all of the listed (rather than mapped) environment variables which didn't have a = in them stopped the segfault in the example.

A quick look made me think the issue is around here but I am not sure; I think there is enough for someone to look into. This is a bug rather than a rough edge from exceptional use, as this is supported by docker-compose.

@hangyan
Copy link
Contributor

hangyan commented Feb 24, 2018

@cdrage should be fixed by #926

@hangyan
Copy link
Contributor

hangyan commented Apr 2, 2018

close by #926

@hangyan hangyan closed this as completed Apr 2, 2018
@weiye-Lee
Copy link

One thing to check if if you've got any blank environment variables within it. That may be one of the reasons. For example, if you have:

env:
  - MYSECRETPASS

and echo $MYSECRETPASS is blank it may be erroring.

Thanks @cdrage , it help me a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants