textileio/go-threads

Calling net.Record.PrevID() crashes when the client is closing

merlinran opened this issue · 2 comments

Same for other methods I believe. Caught this because I mistakenly closed the client while processing records in another goroutine.

Error getting record: rpc error: code = Unavailable desc = transport is closing
...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x1fe57cd]
...

It isn't necessarily a bug, but it would be better if the panic reveals the root problem more apparently. For example, we could have a null object which panics more soundly before the record is loaded.

Is that due to net.Record.obj being nil? Seems odd that it's related to the client closing, but likely I'm missing a connection here.

Maybe not nil because addr is not zero. It stops complaining once I remove the line to close the client.