SPOP with COUNT bug
Calling SPOP with a specified COUNT causes a server crash.
Repro: 127.0.0.1:3278> sadd key1 "1" "2" "3" (integer) 3 127.0.0.1:3278> spop key1 3 Error: Server closed the connection
Stack Trace: ProcessMessages threw exception System.ArgumentException: Range of random number does not contain at least one possibility. at System.Security.Cryptography.RandomNumberGenerator.GetInt32(Int32 fromInclusive, Int32 toExclusive) at Garnet.server.SetObject.SetPop(Byte* input, Int32 length, SpanByteAndMemory& output) in D:\Git\GarnetGitHub\libs\server\Objects\Set\SetObjectImpl.cs:line 179 at Garnet.server.SetObject.Operate(SpanByte& input, SpanByteAndMemory& output, Int64& sizeChange) in D:\Git\GarnetGitHub\libs\server\Objects\Set\SetObject.cs:line 121 at Garnet.server.ObjectStoreFunctions.InPlaceUpdaterWorker(Byte[]& key, SpanByte& input, IGarnetObject& value, GarnetObjectStoreOutput& output, RMWInfo& rmwInfo, Int64& sizeChange) in D:\Git\GarnetGitHub\libs\server\Storage\Functions\ObjectStore\RMWMethods.cs:line 90 at Garnet.server.ObjectStoreFunctions.InPlaceUpdater(Byte[]& key, SpanByte& input, IGarnetObject& value, GarnetObjectStoreOutput& output, RMWInfo& rmwInfo, RecordInfo& recordInfo) in D:\Git\GarnetGitHub\libs\server\Storage\Functions\ObjectStore\RMWMethods.cs:line 51 at Garnet.server.StorageSession.RMWObjectStoreOperationWithOutput[TObjectContext](Byte[] key, ArgSlice input, TObjectContext& objectStoreContext, GarnetObjectStoreOutput& outputFooter) in D:\Git\GarnetGitHub\libs\server\Storage\Session\ObjectStore\Common.cs:line 55 at Garnet.server.StorageSession.SetPop[TObjectContext](Byte[] key, ArgSlice input, GarnetObjectStoreOutput& outputFooter, TObjectContext& objectContext) in D:\Git\GarnetGitHub\libs\server\Storage\Session\ObjectStore\SetOps.cs:line 431 at Garnet.server.GarnetApi`2.SetPop(Byte[] key, ArgSlice input, GarnetObjectStoreOutput& outputFooter) in D:\Git\GarnetGitHub\libs\server\API\GarnetApiObjectCommands.cs:line 293 at Garnet.server.RespServerSession.SetPop[TGarnetApi](Int32 count, Byte* ptr, TGarnetApi& storageApi) in D:\Git\GarnetGitHub\libs\server\Resp\Objects\SetCommands.cs:line 421 at Garnet.server.RespServerSession.ProcessArrayCommands[TGarnetApi](TGarnetApi& storageApi) in D:\Git\GarnetGitHub\libs\server\Resp\RespServerSession.cs:line 496 at Garnet.server.RespServerSession.ProcessBasicCommands[TGarnetApi](Byte* ptr, RespCommand cmd, TGarnetApi& storageApi) in D:\Git\GarnetGitHub\libs\server\Resp\RespServerSession.cs:line 368 at Garnet.server.RespServerSession.ProcessMessages() in D:\Git\GarnetGitHub\libs\server\Resp\RespServerSession.cs:line 273 at Garnet.server.RespServerSession.TryConsumeMessages(Byte* reqBuffer, Int32 bytesReceived) in D:\Git\GarnetGitHub\libs\server\Resp\RespServerSession.cs:line 199