KeyDB icon indicating copy to clipboard operation
KeyDB copied to clipboard

[CRASH] `LLEN` or `LPOP` on a key written by `KEYDB.NHSET` with more than one value crashes the server

Open jiren-the-gray opened this issue 1 month ago • 0 comments

Crash report

Paste the complete crash log between the quotes below. Please include a few lines from the log preceding the crash report to provide some context.

1:32:M 28 Oct 2026 14:44:57.346 * DB saved on disk

=== KEYDB BUG REPORT START: Cut & paste starting from here ===
1:32:M 28 Oct 2026 14:44:57.346 # ------------------------------------------------
1:32:M 28 Oct 2026 14:44:57.346 # !!! Software Failure. Press left mouse button to continue
1:32:M 28 Oct 2026 14:44:57.346 # Guru Meditation: Unknown list encoding #t_list.cpp:83

------ STACK TRACE ------

Backtrace:
keydb-server *:6379(listTypeLength(robj_roptr)+0x32) [0x5555558332a2]
keydb-server *:6379(llenCommand(client*)+0x58) [0x555555833648]
keydb-server *:6379(call(client*, int)+0xae) [0x55555588fe9e]
keydb-server *:6379(processCommand(client*, int)+0x71b) [0x555555890dfb]
keydb-server *:6379(processCommandAndResetClient(client*, int)+0x6f) [0x55555586f8af]
keydb-server *:6379(processInputBuffer(client*, bool, int)+0x1ec) [0x555555872d1c]
keydb-server *:6379(processClients()+0x118) [0x555555874698]

Aditional information

  1. OS distribution and version: Docker image eqalpha/keydb:latest (KeyDB 6.3.4, git sha 7e7e5e57) on Ubuntu 22.04, x86_64. src/t_nhash.cpp is unchanged on main.

  2. Steps to reproduce:

    docker run -d --name keydb -p 6379:6379 eqalpha/keydb:latest
    redis-cli KEYDB.NHSET k f v      # (integer) 0
    redis-cli TYPE k                 # list
    redis-cli OBJECT ENCODING k      # "ziplist"
    redis-cli LLEN k                 # connection closed, server panics (LPOP k does the same)
    

    TYPE says list, so any client that sees a list will crash the server with an ordinary list command.

    Potential cause. With more than one value, nhsetCommand (src/t_nhash.cpp:338-350) stores them with createZiplistObject(), which makes an OBJ_LIST with ziplist encoding. KeyDB's list commands accept only quicklist-encoded lists and panic on anything else (t_list.cpp:83).

    Suggested fix. Store the values as a quicklist (createQuicklistObject and listTypePush), or use an object type that the list commands reject with WRONGTYPE.

jiren-the-gray avatar Oct 28 '26 17:10 jiren-the-gray