Skip to content

[BUG] running cli "HKEYS" without passing parameter when enabling teststorageprovider will crash KeyDB server #480

@paulmchen

Description

@paulmchen

Describe the bug

I enabled 'teststorageprovider' in KeyDB open source code base, and test the iStorage interface, and see the KeyDB server crashed when i run the following commands without passing correct parameters. For example: "HKEYS", "HGET"

To reproduce

  1. Use the following redis.conf file to start the keydb server:

bind 127.0.0.1
port 7001
protected-mode no
save ""
storage-provider test
server-threads 2

  1. Run HKEYS command without passing additional parameter

./keydb-cli -h 127.0.0.1 -p 7001
127.0.0.1:7001> HKEYS
Error: Server closed the connection
127.0.0.1:7001>

The keydb server crashed.

Here is the stack trace:

=== KEYDB BUG REPORT START: Cut & paste starting from here ===
3030:3038:M 29 Jul 2022 22:26:24.064 # ------------------------------------------------
3030:3038:M 29 Jul 2022 22:26:24.064 # !!! Software Failure. Press left mouse button to continue
3030:3038:M 29 Jul 2022 22:26:24.064 # Guru Meditation: KeyDB built-in command declared keys positions not matching the arity requirements. #db.cpp:2182

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

Backtrace:
./keydb-oss-server 127.0.0.1:7001(getKeysUsingCommandTable(redisCommand*, redisObject**, int, getKeysResult*)+0xc8) [0x560cd5bba8b8]
./keydb-oss-server 127.0.0.1:7001(redisDbPersistentData::prefetchKeysAsync(client*, parsed_command&, bool)+0x22f) [0x560cd5bc8cdf]
./keydb-oss-server 127.0.0.1:7001(+0x9800d) [0x560cd5bb300d]
./keydb-oss-server 127.0.0.1:7001(readQueryFromClient(connection*)+0x3e2) [0x560cd5ba8fb2]
./keydb-oss-server 127.0.0.1:7001(connSocketEventHandler(aeEventLoop*, int, void*, int)+0x1d0) [0x560cd5c9c4a0]
./keydb-oss-server 127.0.0.1:7001(ProcessEventCore+0x103) [0x560cd5b76f93]
./keydb-oss-server 127.0.0.1:7001(aeProcessEvents+0x1e5) [0x560cd5b7af15]
./keydb-oss-server 127.0.0.1:7001(aeMain+0x3e) [0x560cd5b7b78e]
./keydb-oss-server 127.0.0.1:7001(workerThreadMain(void*)+0x1a0) [0x560cd5b92e40]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7f50652e76db]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f506501061f]

Expected behavior

Server should not crash. cli should return "incorrect parameter used for the command" instead.

Additional information

Any additional information that is relevant to the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions