gammons / ultralist

Simple task management for tech folks.
https://ultralist.io
MIT License
955 stars 106 forks source link

SIGSEGV on Termux / Android #179

Closed afandian closed 4 years ago

afandian commented 5 years ago

arm build runs on Android to show home screen but can't do anything with files.

I think this is caused by storage access?

$ cd ~
$ pwd
/data/data/com.termux/files/home                                                                                               $ ultralist init
Repo initialized.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x24 pc=0x35ed0c]

goroutine 1 [running]:
github.com/ultralist/ultralist/ultralist.(*Backend).credsFolderPath(0x100c730, 0x1016200, 0x35e030)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/backend.go:128 +0x18
github.com/ultralist/ultralist/ultralist.(*Backend).credsFilePath(...)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/backend.go:132
github.com/ultralist/ultralist/ultralist.(*Backend).CredsFileExists(0x100c730, 0x100c730)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/backend.go:88 +0x20
github.com/ultralist/ultralist/ultralist.NewBackend(0x5774a0)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/backend.go:29 +0x2c
github.com/ultralist/ultralist/ultralist.(*App).InitializeRepo(0x100b860)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/app.go:42 +0x80
github.com/ultralist/ultralist/cmd.glob..func16(0x8a2458, 0x8b7a2c, 0x0, 0x0)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/cmd/init.go:18 +0x18
github.com/ultralist/ultralist/vendor/github.com/spf13/cobra.(*Command).execute(0x8a2458, 0x8b7a2c, 0x0, 0x0, 0x8a2458, 0x8b7a2c)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/vendor/github.com/spf13/cobra/command.go:766 +0x204
github.com/ultralist/ultralist/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x8a2f08, 0x0, 0x3ffd4, 0x4065dc)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/vendor/github.com/spf13/cobra/command.go:852 +0x22c
github.com/ultralist/ultralist/vendor/github.com/spf13/cobra.(*Command).Execute(...)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/vendor/github.com/spf13/cobra/command.go:800
github.com/ultralist/ultralist/cmd.Execute()
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/cmd/root.go:23 +0x24
main.main()
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/main.go:8 +0x14
...
gammons commented 5 years ago

huh, what happens if you create the ~/.config/ultralist directory manually?

afandian commented 5 years ago

Thanks. Different error this time

mkdir ~/.config/ultralist
$ ultralist init
It looks like a .todos.json file already exists!  Doing nothing.
$ ultralist l
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x24 pc=0x362cc4]

goroutine 1 [running]:
github.com/ultralist/ultralist/ultralist.(*FileStore).GetLocation(0xc0c710, 0x3, 0xf0d04004)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/file_store.go:86 +0x78
github.com/ultralist/ultralist/ultralist.(*FileStore).Load(0xc0c710, 0xc3, 0x4050c8, 0x32, 0x20, 0x1)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/file_store.go:42 +0x26c
github.com/ultralist/ultralist/ultralist.(*App).Load(0xc0b840, 0x471378, 0x8a82a0)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/app.go:372 +0x28
github.com/ultralist/ultralist/ultralist.(*App).ListTodos(0xc0b840, 0x0, 0x0)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/ultralist/app.go:287 +0x1c
github.com/ultralist/ultralist/cmd.glob..func17(0x8a2588, 0x8b7a2c, 0x0, 0x0)
        /home/grant-work/code/go/src/github.com/ultralist/ultralist/cmd/list.go:56 +0x64
github.com/ultralist/ultralist/vendor/github.com/spf13/cobra.(*Command).execute(0x8a2588, 0x8b7a2c, 0x0, 0x0, 0x8a2588, 0x8b7a2c)
        /home
...
afandian commented 5 years ago

Looking at both stack traces, I think this is probably user.Current(). You ignore the return error from that here and here, but maybe that doesn't play nicely with the termux environment. It may just be a problem in the Go library.

($HOME is set to /data/data/com.termux/files/home by the way)

At the very least, a controlled abort (rather than ignore) if you can't get the user would help narrow it down.

afandian commented 5 years ago

Okay, so I think this is the answer: https://golang.org/src/os/user/lookup_android.go

gammons commented 5 years ago

@afandian I'd be happy to accept a PR! Looks like you're nearly there with a solution.

gammons commented 5 years ago

Also, I'm not sure your use case, but you might want to look into ultralist.io for managing your lists on mobile. The webapp is a progressive web app that works really well on android devices.

afandian commented 5 years ago

I'll certainly have a go at a PR, looks doable. I have an android with a keyboard (Gemini PDA) and I love ultralist CLI on the desktop. So the webapp is nice but I like the idea of having the same thing on my mobile.

gammons commented 5 years ago

We were just talking about this in an earlier PR. https://github.com/ultralist/ultralist/pull/168#discussion_r266818443

Maybe using os.UserHomeDir() is the right way to fix this?

timorunge commented 5 years ago

I've created a little PR for this: #181

@afandian maybe you can test this branch and see if this is working for you.