redis-rb / redis-client

Simple low level client for Redis 6+
MIT License
124 stars 60 forks source link

BufferedIO#gets_integer: remove optimistic EOL optimization #191

Closed casperisfine closed 6 months ago

casperisfine commented 6 months ago

Tentative fix for https://github.com/redis-rb/redis-client/issues/190

I wasn't able to reproduce, not to really figure out the root cause.

Unknown sigil type: "\r" suggest we corrupted the offset after calling gets_integer. When we read \r we assume \n is next but don't check if we read it yet, and just increment the offset, and the offset can potentially be past the buffer.

I don't know how it happens exactly, but somehow we sometimes don't handle this case properly.

The fact that it was reported with a pubsub use case suggest it might be after a read timeout, but can't be certain.