graw icon indicating copy to clipboard operation
graw copied to clipboard

Segfault when using the example code

Open Xe opened this issue 2 years ago • 0 comments

I have a bot that monitors a subreddit for new posts and posts them to Discord. The source code is here. I am getting a confusing segfault when I try to monitor posts on a subreddit:

$ go run . -subreddit shadowh511
2022/03/08 20:57:44 listening for new posts on /r/shadowh511
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x73b9df]

goroutine 1 [running]:
github.com/turnage/graw/streams/internal/monitor.(*monitor).harvest(0xc0000be3c0, {0x0, 0x741501})
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/streams/internal/monitor/monitor.go:92 +0x7f
github.com/turnage/graw/streams/internal/monitor.(*monitor).sync(0xc0000be3c0)
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/streams/internal/monitor/monitor.go:99 +0x29
github.com/turnage/graw/streams/internal/monitor.New({{0xc0000326d8, 0x11}, {0x0, 0x0}, {0x86c7e0, 0xb3d280}})
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/streams/internal/monitor/monitor.go:69 +0x105
github.com/turnage/graw/streams.monitorFromPath({0xc0000326d8, 0x3}, {0x0, 0x0})
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/streams/streams.go:227 +0x92
github.com/turnage/graw/streams.streamFromPath({0x0, 0x0}, 0x7f0b64365f98, 0x7fffe52d45a5, {0xc0000326d8, 0x7ee5ad})
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/streams/streams.go:217 +0x45
github.com/turnage/graw/streams.Subreddits({0x0, 0x0}, 0xc0000aa300, 0xc0000001a0, {0xc0001c94a0, 0xc0000001a0, 0x300000002})
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/streams/streams.go:64 +0x90
github.com/turnage/graw.connectScanStreams({0x7828e0, 0xc0000aa300}, {0x0, 0x0}, {{0xc0001c94a0, 0x1, 0x1}, 0x0, {0x0, 0x0, ...}, ...}, ...)
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/scan.go:71 +0xd3
github.com/turnage/graw.connectAllStreams({0x7828e0, 0xc0000aa300}, {0x0, 0x0}, {{0xc0001c94a0, 0x1, 0x1}, 0x0, {0x0, 0x0, ...}, ...}, ...)
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/run.go:58 +0xbe
github.com/turnage/graw.Run({0x7828e0, 0xc0000aa300}, {0x0, 0x0}, {{0xc0001c94a0, 0x1, 0x1}, 0x0, {0x0, 0x0, ...}, ...})
	/home/cadey/code/cadey/snoo2nebby/vendor/github.com/turnage/graw/run.go:38 +0xc5
main.main()
	/home/cadey/code/cadey/snoo2nebby/main.go:92 +0x2d7
exit status 2

I am using graw version v0.0.0-20201204201853-a177df1b5c91 according to my go.mod file, but I am unable to figure out what the problem is. Am I missing something very obvious?

Thanks for looking into this and be well.

Xe avatar Mar 09 '22 01:03 Xe