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

Segfault when Scheme not defined #1050

Closed
trimoq opened this issue Apr 10, 2019 · 2 comments · Fixed by #1059
Closed

Segfault when Scheme not defined #1050

trimoq opened this issue Apr 10, 2019 · 2 comments · Fixed by #1059

Comments

@trimoq
Copy link

trimoq commented Apr 10, 2019

Wskdeploy crashes with a Segfault when the URL Scheme is not defined in apihost:

To reproduce the segfault:

wsk property set --auth ....
wsk property set --apihost 192.168.55.5:31001
wskdeploy

in contrast, the following works:

wsk property set --auth ....
wsk property set --apihost https://192.168.55.5:31001
wskdeploy

The segfault seems to originate this code

the error:

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

goroutine 1 [running]:
github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/apache/incubator-openwhisk-client-go/whisk.GetUrlBase(0x7fff505c4404, 0x12, 0x1, 0x1, 0xc4201269c0)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/apache/incubator-openwhisk-client-go/whisk/wskprops.go:72 +0xea
github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/apache/incubator-openwhisk-client-go/whisk.NewClient(0xc420256180, 0xc420226c80, 0x0, 0x0, 0xc420226c80)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/apache/incubator-openwhisk-client-go/whisk/client.go:130 +0x778
github.com/apache/incubator-openwhisk-wskdeploy/deployers.glob..func5(0xc420226c80, 0x15, 0x0, 0x0)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/deployers/whiskclient.go:81 +0x53
github.com/apache/incubator-openwhisk-wskdeploy/cmd.Deploy(0xb09ba0, 0x1, 0xc420116238)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/cmd/root.go:231 +0x4a7
github.com/apache/incubator-openwhisk-wskdeploy/cmd.RootCmdImp(0xb09ba0, 0xc42010c7e0, 0x0, 0x6, 0x0, 0x0)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/cmd/root.go:51 +0x2b
github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/spf13/cobra.(*Command).execute(0xb09ba0, 0xc420092010, 0x6, 0x6, 0xb09ba0, 0xc420092010)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/spf13/cobra/command.go:632 +0x3e8
github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xb09ba0, 0x0, 0xb0a200, 0x1)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/spf13/cobra/command.go:722 +0x2fe
github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/spf13/cobra.(*Command).Execute(0xb09ba0, 0x7, 0x7)
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/vendor/github.com/spf13/cobra/command.go:681 +0x2b
github.com/apache/incubator-openwhisk-wskdeploy/cmd.Execute()
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/cmd/root.go:65 +0xe4
main.main()
	/home/travis/gopath/src/github.com/apache/incubator-openwhisk-wskdeploy/main.go:26 +0x20

Do we have to set the scheme in the apihost or should the code in GetUrlBase handle this correctly?

@trimoq
Copy link
Author

trimoq commented Apr 11, 2019

Ok, according to the go docs:

Trying to parse a hostname and path without a scheme is invalid but may not necessarily return an error, due to parsing ambiguities.

If the code in the go client is modified to the following, a missing schema is not causing a segfault anymore.

// was:    if len(url.Scheme) == 0 || len(url.Host) == 0 { 
if url==nil || len(url.Scheme) == 0 || len(url.Host) == 0 { 
  urlBase = fmt.Sprintf("https://%s/api", host)
  url, err = url.Parse(urlBase)
}

Does this has to be fixed or must the user set the scheme in the first place?

@dgrove-oss
Copy link
Member

The user should not be required to set the scheme. Sorry this issue got overlooked for two months.

dgrove-oss added a commit to dgrove-oss/openwhisk-wskdeploy that referenced this issue Jul 1, 2019
Update client-go to latest; Fixes apache#1050.
dgrove-oss added a commit that referenced this issue Jul 2, 2019
Update client-go to latest; Fixes #1050.
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

Successfully merging a pull request may close this issue.

2 participants