Skip to content

listpack over 8192 cause 'error: cursor out of range' panic error #24

@freekatz

Description

@freekatz

Thanks for your awesome work! I found a bug when I test the rdb tool on my Mac about Redis7.2.

  • redis
redis-server -v                                          
Redis server v=7.2.1 sha=00000000:0 malloc=libc bits=64 build=7b8617dd94058f85
  • test data
redis-benchmark -c 1  --dbnum 0 -d 10000 -r 2000 -t rpush
  • code should be
         //  https://github.com/HDT3213/rdb/blob/887c2ca2556ffff3be967e74147ec5fe428af8b1/core/listpack.go#L105
	case 0: // 1111 0000 -> str, 4 bytes len
		var lenBytes []byte
		lenBytes, err = readBytes(buf, cursor, 4)
		if err != nil {
			return nil, 0, err
		}
		//strLen := int(binary.BigEndian.Uint32(lenBytes))
		strLen := int(binary.LittleEndian.Uint32(lenBytes))
		result, err := readBytes(buf, cursor, strLen)
		if err != nil {
			return nil, 0, err
		}
		//length = readVarInt(buf, cursor) // read element length
		length = uint32(len(result)) // read element length
		return result, length, nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions