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 when calling Set() on Ubuntu 20.04 on WSL #54

Closed
Piccirello opened this issue Jan 6, 2021 · 5 comments · Fixed by #55
Closed

Panic when calling Set() on Ubuntu 20.04 on WSL #54

Piccirello opened this issue Jan 6, 2021 · 5 comments · Fixed by #55
Labels
bugfix Bug fixes and patches

Comments

@Piccirello
Copy link
Contributor

Piccirello commented Jan 6, 2021

Calling keyring.Set() on Ubuntu 20.04 on WSL results in the following panic: panic: runtime error: slice bounds out of range. On Ubuntu 18.04 on the same machine, keyring.Set() fails more gracefully, returning the error exec: "dbus-launch": executable file not found in $PATH. I've included a minimal PoC to reproduce.

OS: Microsoft Windows Server Version 1809

package main

import (
	"fmt"

	"github.com/zalando/go-keyring"
)

func main() {
	if err := keyring.Set("my-service", "foo", "bar"); err != nil {
		fmt.Printf("Error: %s", err)
	} else {
		fmt.Printf("Success!")
	}
}

Ubuntu 20.04 on WSL:

thomas@windows-server-2019:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
thomas@windows-server-2019:~$ /mnt/c/Users/thomas/Desktop/keyring
panic: runtime error: slice bounds out of range [308:282]

goroutine 1 [running]:
github.com/godbus/dbus.getSessionBusPlatformAddress(0x59090f, 0x18, 0x0, 0x0)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn_other.go:30 +0x295
github.com/godbus/dbus.getSessionBusAddress(0x0, 0x0, 0x0, 0x0)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn.go:96 +0xf8
github.com/godbus/dbus.SessionBusPrivate(0x7f85a58ece20, 0xc00008cd18, 0x40d430)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn.go:101 +0x25
github.com/godbus/dbus.SessionBus(0x0, 0x0, 0x0)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn.go:73 +0xb5
github.com/zalando/go-keyring/secret_service.NewSecretService(0x40d430, 0xc00008cd80, 0x44bfa5)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/zalando/go-keyring@v0.1.0/secret_service/secret_service.go:50 +0x26
github.com/zalando/go-keyring.secretServiceProvider.Set(0x58d634, 0xa, 0x58c369, 0x3, 0x58c357, 0x3, 0x0, 0x0)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/zalando/go-keyring@v0.1.0/keyring_linux.go:14 +0x5d
github.com/zalando/go-keyring.Set(...)
        /Users/thomas/Documents/projects/go/pkg/mod/github.com/zalando/go-keyring@v0.1.0/keyring.go:27
main.main()
        /Users/thomas/Documents/projects/go/src/github.com/DopplerHQ/cli/keyring-poc.go:10 +0x78

Ubuntu 18.04 on WSL:

thomas@windows-server-2019:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic
thomas@windows-server-2019:~$ /mnt/c/Users/thomas/Desktop/keyring
Error: exec: "dbus-launch": executable file not found in $PATH
@mikkeloscar
Copy link
Member

Thanks for reporting this. Since this panic happens deep inside the godbus library it may have to be reported there if there is a way to replicate it outside of go-keyring. As a first step we could try to update the library version and see if it has already been addressed.

@mikkeloscar mikkeloscar added the bugfix Bug fixes and patches label Jan 12, 2021
@Piccirello
Copy link
Contributor Author

Aha! That update seems to have fixed the panic:

Build:

thomas $ go get github.com/zalando/go-keyring@4d37811583adde6f2c303662712b318405f279ff
go: github.com/zalando/go-keyring 4d37811583adde6f2c303662712b318405f279ff => v0.1.1-0.20210112083600-4d37811583ad
go: downloading github.com/zalando/go-keyring v0.1.1-0.20210112083600-4d37811583ad
go: downloading github.com/godbus/dbus/v5 v5.0.3
thomas $ GOOS=linux go build -o keyring keyring-poc.go 

Execution:

thomas@windows-server-2019:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
thomas@windows-server-2019:~$ /mnt/c/Users/thomas/Desktop/keyring
Error: dbus: couldn't determine address of session bus

@mikkeloscar
Copy link
Member

Cool! Thanks for testing it!

@Piccirello
Copy link
Contributor Author

Thanks for putting up a fix! Will there be a new release for these changes, or should I remain pinned to the specific commit?

@mikkeloscar
Copy link
Member

@Piccirello We have made a new release now: https://github.com/zalando/go-keyring/releases/tag/v0.1.1

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

Successfully merging a pull request may close this issue.

2 participants