jhunters / bigqueue

Golang implements for BigQueue
Apache License 2.0
56 stars 24 forks source link

fix: prevent nil pointer error on FreeSubscribe #19

Closed golikov closed 2 years ago

golikov commented 3 years ago

It is quite easy to get this panic in case somehow FreeSubscribe function is called, while doLoopSubscribe is still in the middle of the innermost loop:

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

goroutine 49 [running]: github.com/jhunters/bigqueue.(FileQueue).doLoopSubscribe(0xc0000b6370) /Users/nickgolikov/go/pkg/mod/github.com/jhunters/bigqueue@v1.2.2/filequeue.go:805 +0x54 created by github.com/jhunters/bigqueue.(FileQueue).Subscribe /Users/nickgolikov/go/pkg/mod/github.com/jhunters/bigqueue@v1.2.2/filequeue.go:775 +0x70

Which can happen in case the processing function, added in Subscribe, has any blocking logic with channels, for example, and the FreeSubscribe is called in some other routine. Or if the FreeSubscribe is called in the subscribed function itself (I added the test purely for demonstration purposes, prior to proposed changes that test would trigger a panic).

golikov commented 2 years ago

Any update on this? Is this project still being supported?