sachaos / todoist

Todoist CLI Client. I ❤️ Todoist and CLI.
MIT License
1.48k stars 104 forks source link

panic when running sync #192

Open Araly opened 2 years ago

Araly commented 2 years ago

I installed https://aur.archlinux.org/packages/todoist, gave it my API key, and ran sync, but it failed with a panic

It seems like it's trying to use the files in the yay cache, which really sounds like they shouldn't. I tried clearing out the cache but I still get the same error.

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

goroutine 1 [running]:
github.com/sachaos/todoist/lib.addToChildItem(...)
        /home/araly/.cache/yay/todoist/src/go/src/github.com/sachaos/todoist/lib/sync.go:99
github.com/sachaos/todoist/lib.(*Store).ConstructItemTree(0xc0000c0e00)
        /home/araly/.cache/yay/todoist/src/go/src/github.com/sachaos/todoist/lib/sync.go:176 +0x2a3
github.com/sachaos/todoist/lib.(*Client).Sync(0xc000092f00, {0x8d45f0, 0xc0000a8000})
        /home/araly/.cache/yay/todoist/src/go/src/github.com/sachaos/todoist/lib/todoist.go:116 +0x1df
main.Sync(0x1?)
        /home/araly/.cache/yay/todoist/src/go/src/github.com/sachaos/todoist/sync.go:12 +0x69
github.com/urfave/cli.HandleAction({0x7b7920?, 0x85f018?}, 0x4?)
        /home/araly/.cache/yay/todoist/src/go/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:490 +0x5a
github.com/urfave/cli.Command.Run({{0x82894b, 0x4}, {0x0, 0x0}, {0xc000091470, 0x1, 0x1}, {0x82a91b, 0xa}, {0x0, ...}, ...}, ...)
        /home/araly/.cache/yay/todoist/src/go/pkg/mod/github.com/urfave/cli@v1.20.0/command.go:210 +0x8f7
github.com/urfave/cli.(*App).Run(0xc0000836c0, {0xc0000b6000, 0x2, 0x2})
        /home/araly/.cache/yay/todoist/src/go/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:255 +0x7e7
main.main()
        /home/araly/.cache/yay/todoist/src/go/src/github.com/sachaos/todoist/main.go:326 +0x1aff
bagrounds commented 1 year ago

Same.

brew tap sachaos/todoist
brew install todoist
todoist
# Input API Token
todoist sync
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x38 pc=0x1006cba24]

goroutine 1 [running]:
github.com/sachaos/todoist/lib.addToChildItem(...)
        /private/tmp/todoist-20221116-8537-c4yeh1/todoist-0.15.0/lib/sync.go:93
github.com/sachaos/todoist/lib.(*Store).ConstructItemTree(0x1400012ae00)
        /private/tmp/todoist-20221116-8537-c4yeh1/todoist-0.15.0/lib/sync.go:165 +0x204
github.com/sachaos/todoist/lib.(*Client).Sync(0x14000158e00, {0x1008cc030, 0x1400011a000})
        /private/tmp/todoist-20221116-8537-c4yeh1/todoist-0.15.0/lib/todoist.go:116 +0x19c
main.Sync(0x1?)
        /private/tmp/todoist-20221116-8537-c4yeh1/todoist-0.15.0/sync.go:12 +0x74
github.com/urfave/cli.HandleAction({0x1008559c0?, 0x1008c7350?}, 0x4?)
        /Users/bgrounds/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:490 +0x6c
github.com/urfave/cli.Command.Run({{0x100775411, 0x4}, {0x0, 0x0}, {0x140001133c0, 0x1, 0x1}, {0x1007772e7, 0xa}, {0x0, ...}, ...}, ...)
        /Users/bgrounds/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/urfave/cli@v1.20.0/command.go:210 +0x6bc
github.com/urfave/cli.(*App).Run(0x14000107380, {0x1400012c000, 0x2, 0x2})
        /Users/bgrounds/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:255 +0x59c
main.main()
        /private/tmp/todoist-20221116-8537-c4yeh1/todoist-0.15.0/main.go:274 +0x14e4
todoist --version
todoist version 0.15.0
sw_vers
ProductName:    macOS
ProductVersion: 12.4
BuildVersion:   21F79
joshterrill commented 1 year ago

Do any of the release binaries work for you? https://github.com/sachaos/todoist/releases

I have a MacOS as well, and downloaded my binary from the link above, renamed it, marked it executable, and threw it into my /usr/local/bin directory and all was good.

Araly commented 1 year ago

Do any of the release binaries work for you? https://github.com/sachaos/todoist/releases

I have a MacOS as well, and downloaded my binary from the link above, renamed it, marked it executable, and threw it into my /usr/local/bin directory and all was good.

I get the exact same issue with this new binary

cscutcher commented 1 year ago

edit: Coming back to this issue, I think I'm seeing something different given that my issue occurs on list and that github.com/sachaos/todoist/lib.Item.LabelsString in the trace is different than other comments. Apologies for muddying the waters!

Created #232 for my issue.

Original comment Seeing the same thing on Arch Linux either user release binary or Nix (as a package manager) ```console ❯ uname -srvo Linux 6.1.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 31 Dec 2022 17:40:35 +0000 GNU/Linux ❯ nix run nixpkgs-master#todoist -- list panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6c380d] goroutine 1 [running]: github.com/sachaos/todoist/lib.Item.LabelsString({{{{0xc000135a10, 0xa}}, {{0xc000135a20, 0xa}}, {0xc000135a30, 0xc}, {0xc000135a40, 0x8}}, {0x0}, {0x0}, ...}, ...) github.com/sachaos/todoist/lib/item.go:215 +0xed main.List.func1(0xc0002809c0, 0x0?) github.com/sachaos/todoist/list.go:72 +0x31b main.traverseItems(0xc0002809c0, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:13 +0x2e main.traverseItems(0xc000280888, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000280750, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000280618, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc0002804e0, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc0002803a8, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000280270, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000280138, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000003180, 0xc0000bebd8, 0x0) github.com/sachaos/todoist/list.go:20 +0x74 main.List(0xc0000d6420) github.com/sachaos/todoist/list.go:58 +0x296 github.com/urfave/cli.HandleAction({0x7b9900?, 0x861398?}, 0x4?) github.com/urfave/cli@v1.20.0/app.go:490 +0x5a github.com/urfave/cli.Command.Run({{0x82ab28, 0x4}, {0x0, 0x0}, {0xc000075400, 0x1, 0x1}, {0x82e4ac, 0xe}, {0x0, ...}, ...}, ...) github.com/urfave/cli@v1.20.0/command.go:210 +0x8f7 github.com/urfave/cli.(*App).Run(0xc0000dc9c0, {0xc000016040, 0x2, 0x2}) github.com/urfave/cli@v1.20.0/app.go:255 +0x7e7 main.main() github.com/sachaos/todoist/main.go:326 +0x1aff ❯ nix flake metadata nixpkgs-master Resolved URL: github:NixOS/nixpkgs/master Locked URL: github:NixOS/nixpkgs/6465e9428e678d178365a3ff2bc88556ad281083 Description: A collection of packages for the Nix package manager Path: /nix/store/mnlxlzwmiq0ag77f7fnqkhdhnzw1zbww-source Revision: 6465e9428e678d178365a3ff2bc88556ad281083 Last modified: 2023-02-06 13:43:44 ❯ nix run nixpkgs-master#todoist -- --version todoist version 0.18.0 ❯ ~/Downloads/todoist_linux_amd64 list panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6bfa6d] goroutine 1 [running]: github.com/sachaos/todoist/lib.Item.LabelsString({{{{0xc00019d960, 0xa}}, {{0xc00019d970, 0xa}}, {0xc00019d980, 0xc}, {0xc00019d990, 0x8}}, {0x0}, {0x0}, ...}, ...) /Users/sachaos/dev/github.com/sachaos/todoist/lib/item.go:215 +0xed main.List.func1(0xc0003009c0, 0x0?) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:72 +0x31b main.traverseItems(0xc0003009c0, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:13 +0x2e main.traverseItems(0xc000300888, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000300750, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000300618, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc0003004e0, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc0003003a8, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000300270, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000300138, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.traverseItems(0xc000003180, 0xc000124bd8, 0x0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:20 +0x74 main.List(0xc00013c6e0) /Users/sachaos/dev/github.com/sachaos/todoist/list.go:58 +0x296 github.com/urfave/cli.HandleAction({0x7b5f00?, 0x85cf50?}, 0x4?) /Users/sachaos/go/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:490 +0x5a github.com/urfave/cli.Command.Run({{0x82686c, 0x4}, {0x0, 0x0}, {0xc000073400, 0x1, 0x1}, {0x82a219, 0xe}, {0x0, ...}, ...}, ...) /Users/sachaos/go/pkg/mod/github.com/urfave/cli@v1.20.0/command.go:210 +0x8f7 github.com/urfave/cli.(*App).Run(0xc000180000, {0xc000014040, 0x2, 0x2}) /Users/sachaos/go/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:255 +0x7e7 main.main() /Users/sachaos/dev/github.com/sachaos/todoist/main.go:326 +0x1aff ❯ ~/Downloads/todoist_linux_amd64 --version todoist version 0.18.0 ``` older versions of nixpkgs have pre 0.18.0 so fail due to (I assume) #201
kenliu commented 1 year ago

I believe the workaround in #228 might resolve these issues. Could you all try the workaround (clean up orphaned tasks) and see if that resolves the panic?