KeyDB icon indicating copy to clipboard operation
KeyDB copied to clipboard

[BUG] Missing check for serverTL in unlinkClient

Open keithchew opened this issue 1 year ago • 0 comments

Testing on v6.3.4, got this crash:

------ STACK TRACE ------
EIP:
/opt/KeyDB/bin/keydb-server *:6379(unlinkClient(client*)+0x345) [0x563dfad38505]

Backtrace:
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14420) [0x7fc8299f8420]
/opt/KeyDB/bin/keydb-server *:6379(unlinkClient(client*)+0x345) [0x563dfad38505]
/opt/KeyDB/bin/keydb-server *:6379(freeClient(client*)+0x3f1) [0x563dfad39071]
/opt/KeyDB/bin/keydb-server *:6379(RM_FreeThreadSafeContext(RedisModuleCtx*)+0x78) [0x563dfae05818]

I traced this and unlinkClient() in networking.cpp has a line which assumes serverTL is available, but it is not. The fix is a simple one:

...
    if (serverTL) {
        serverTL->vecclientsProcess.erase(std::remove(serverTL->vecclientsProcess.begin(), serverTL->vecclientsProcess.end(), c), serverTL->vecclientsProcess.end());
...

keithchew avatar Mar 28 '24 22:03 keithchew