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

check if err is nil before printing it #181

Merged
merged 1 commit into from
Nov 6, 2017

Conversation

suhussai
Copy link
Contributor

@suhussai suhussai commented Nov 3, 2017

So I noticed that when exiting out of the bootstrap setup server using Ctrl-C, the script would throw a runtime error similar to this:

atlantis is running  [press Ctrl-c to exit]
⠋ ^C
shutdown signal received, exiting....

Thank you for using atlantis :)
For more information about how to use atlantis in production go to: https://github.com/hootsuite/atlantis
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1495947]

goroutine 1 [running]:
github.com/hootsuite/atlantis/cmd.(*BootstrapCmd).Init.func1(0xc4200a1440, 0x19295e8, 0x0, 0x0, 0x0, 0x0)
	/Users/umair/src/github.com/hootsuite/atlantis/cmd/bootstrap.go:21 +0x47
github.com/hootsuite/atlantis/vendor/github.com/spf13/cobra.(*Command).execute(0xc4200a1440, 0x19295e8, 0x0, 0x0, 0xc4200a1440, 0x19295e8)
	/Users/umair/src/github.com/hootsuite/atlantis/vendor/github.com/spf13/cobra/command.go:650 +0x456
github.com/hootsuite/atlantis/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x19028e0, 0x2, 0x4, 0x0)
	/Users/umair/src/github.com/hootsuite/atlantis/vendor/github.com/spf13/cobra/command.go:729 +0x2fe
github.com/hootsuite/atlantis/vendor/github.com/spf13/cobra.(*Command).Execute(0x19028e0, 0x1902a28, 0xc42010ff58)
	/Users/umair/src/github.com/hootsuite/atlantis/vendor/github.com/spf13/cobra/command.go:688 +0x2b
github.com/hootsuite/atlantis/cmd.Execute()
	/Users/umair/src/github.com/hootsuite/atlantis/cmd/root.go:17 +0x2d
main.main()
	/Users/umair/src/github.com/hootsuite/atlantis/main.go:21 +0x4b1

Took a bit of time to find it, but I think I found the solution. Turns out it was trying to dereference nil (err.Error()) which was the value of err in the case when a user hits Ctrl-C to exit of the server.

With that small nil check added, it exited out of the bootstrap server a bit more gracefully.

Hope this helps and Atlantis looks great by the way! 👍

@CLAassistant
Copy link

CLAassistant commented Nov 3, 2017

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@lkysow lkysow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice find. Please sign the CLA before we can merge.

@lkysow lkysow merged commit 2c45288 into hootsuite:master Nov 6, 2017
@suhussai suhussai deleted the bootstrap_error_fix branch November 6, 2017 02:33
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 this pull request may close these issues.

3 participants