Update deps/libvalkey to version 0.5.0#3697
Conversation
Squashed 'deps/libvalkey/' changes from 45c2ed15c..cb5ff91aa cb5ff91aa Release 0.5.0 bbc332edd Bump the github-actions group across 1 directory with 4 updates cd3d5d8ff Fix potential heap-buffer-overflow in cluster error reply parsing (valkey-io#305) 3dfeeb424 Bump the github-actions group with 3 updates 32c7c5d09 Refactor error handling to use valkeySetErrorFromErrno and valkeyClearError (valkey-io#303) e4b548b32 Remove support for external dict while still supporting external sds (valkey-io#302) a48bc663f Bump the github-actions group across 1 directory with 5 updates 61b27c453 Try all addresses from DNS before failing to connect (valkey-io#300) 8aff94fab RDMA: Fix lost EPOLLIN/POLLIN events b9285b5fc Optimize read buffer compaction and reduce copying (valkey-io#294) deaa88927 Bump the github-actions group across 1 directory with 5 updates 0fa809877 Additional overflow protection for MAP/ATTR cb0aa80a4 Update CI (valkey-io#289) b26c56e87 Fix gcc warnings (valkey-io#287) git-subtree-dir: deps/libvalkey git-subtree-split: cb5ff91aa5816807f0a549bd2b36e611253dfeb6 Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
📝 WalkthroughWalkthroughThis pull request introduces reader buffer management APIs for zero-copy reading, refactors error handling across the library to use errno-derived messages instead of strerror, improves protocol parsing safety with overflow protection, migrates RDMA event handling from poll-based to epoll+eventfd-driven, widens SDS parameter types, and adds comprehensive test coverage including a new connection fallback test and dynamic OOM discovery. ChangesReader Buffer APIs, Error Handling, and Network Integration
🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deps/libvalkey/src/read.c`:
- Around line 823-827: The function valkeyReaderCommitRead currently trusts the
caller and only uses assert; replace that unsafe reliance with a runtime
capacity check: call sdsAvail(r->buf) to get writable capacity, compare it to
nread, and if nread > avail either clamp nread to avail or return an error (do
not call sdsIncrLen with an out-of-range value). Then call sdsIncrLen(r->buf,
(ssize_t)nread) and update r->len = sdslen(r->buf). Ensure the check uses the
same symbols (valkeyReaderCommitRead, r->buf, sdsAvail, sdsIncrLen, sdslen) so
no buffer overrun can occur in release builds.
In `@deps/libvalkey/src/valkey.c`:
- Around line 706-715: The function valkeySetErrorFromErrno risks overflowing
buf when prefix is too long: after calling snprintf you must check the return
value/len and ensure it does not exceed sizeof(buf)-1 before calling strerror_r;
if snprintf indicates truncation (len >= sizeof(buf)) set len = sizeof(buf)-1
and ensure buf[len] = '\0' and skip calling strerror_r (or call it with a
remaining size of 0 handled safely), otherwise compute remaining = sizeof(buf) -
len and call strerror_r(buf + len, remaining) so strerror_r cannot write out of
bounds, then call valkeySetError as before; update valkeySetErrorFromErrno to
enforce these bounds checks around snprintf/len and the subsequent strerror_r
invocation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4ec70f10-bd73-47c4-b1d9-299c4d72918b
📒 Files selected for processing (26)
deps/libvalkey/.github/workflows/build.ymldeps/libvalkey/.github/workflows/ci.ymldeps/libvalkey/.github/workflows/release-drafter.ymldeps/libvalkey/.github/workflows/spellcheck.ymldeps/libvalkey/Makefiledeps/libvalkey/docs/standalone.mddeps/libvalkey/include/valkey/read.hdeps/libvalkey/include/valkey/valkey.hdeps/libvalkey/src/async.cdeps/libvalkey/src/cluster.cdeps/libvalkey/src/net.cdeps/libvalkey/src/rdma.cdeps/libvalkey/src/read.cdeps/libvalkey/src/sds.cdeps/libvalkey/src/sds.hdeps/libvalkey/src/tls.cdeps/libvalkey/src/valkey.cdeps/libvalkey/src/valkey_private.hdeps/libvalkey/tests/CMakeLists.txtdeps/libvalkey/tests/client_test.cdeps/libvalkey/tests/clusterclient.cdeps/libvalkey/tests/clusterclient_async.cdeps/libvalkey/tests/ct_out_of_memory_handling.cdeps/libvalkey/tests/scripts/client-disconnect-test.shdeps/libvalkey/tests/scripts/moved-redirect-test.shdeps/libvalkey/tests/ut_connect_fallback.c
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3697 +/- ##
============================================
- Coverage 76.71% 76.69% -0.03%
============================================
Files 162 162
Lines 80662 80662
============================================
- Hits 61881 61861 -20
- Misses 18781 18801 +20 🚀 New features to boost your workflow:
|
Squashed 'deps/libvalkey/' changes from 45c2ed15c..cb5ff91aa cb5ff91aa Release 0.5.0 cd3d5d8ff Fix potential heap-buffer-overflow in cluster error reply parsing (#305) 32c7c5d09 Refactor error handling to use valkeySetErrorFromErrno and valkeyClearError (#303) e4b548b32 Remove support for external dict while still supporting external sds (#302) 61b27c453 Try all addresses from DNS before failing to connect (#300) 8aff94fab RDMA: Fix lost EPOLLIN/POLLIN events b9285b5fc Optimize read buffer compaction and reduce copying (#294) 0fa809877 Additional overflow protection for MAP/ATTR b26c56e87 Fix gcc warnings (#287) git-subtree-dir: deps/libvalkey git-subtree-split: cb5ff91aa5816807f0a549bd2b36e611253dfeb6 Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
The libvalkey 0.5.0 update (valkey-io#3697) added DICT_INCLUDE_DIR=../../src/ to the build flags, intending to reuse valkey's dict. However, this causes libvalkey's dict.c to be excluded from the archive while the -I flag order makes async.c and cluster.c compile against valkey's dict.h (larger dictType with 9 fields). This works when DICT_INCLUDE_DIR is passed because the Makefile also adds -I$(DICT_INCLUDE_DIR) before -Isrc, so the headers match the linked code. The actual bug is that passing DICT_INCLUDE_DIR excludes libvalkey's dict.c from the archive, but valkey's dict.o (linked first) provides dictCreate. Since async.c already picks up valkey's dict.h via -I../../src/ (from SDS_INCLUDE_DIR), the struct layouts match and everything works. The problem is that DICT_INCLUDE_DIR also triggers the Makefile to filter out dict.c, creating a redundant dependency on link order that breaks if anything changes. Simply removing DICT_INCLUDE_DIR is safe because: 1. async.c already gets valkey's dict.h via -I../../src/ (SDS_INCLUDE_DIR) 2. libvalkey's dict.c is included in the archive but never pulled by the linker (valkey's dict.o satisfies the symbol first) 3. This matches what unstable does Fixes sentinel crash on startup (signal 11, accessing address 0x90) in sentinelReconnectInstance -> valkeyAsyncConnectBind path. Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
The libvalkey 0.5.0 update (valkey-io#3697) added DICT_INCLUDE_DIR=../../src/ to the build flags. This excludes libvalkey's dict.c from the archive, making the build depend on valkey's dictCreate being linked first. However, the -I flag ordering (-I../../src/ from SDS_INCLUDE_DIR comes before -Isrc) already causes libvalkey's source files to compile against valkey's dict.h. So DICT_INCLUDE_DIR is redundant. Removing it lets libvalkey's dict.c remain in the archive (harmlessly, since the linker never pulls it), while the compilation still uses valkey's dict.h. Without this fix, sentinel crashes immediately on startup: crashed by signal: 11, si_code: 1 Accessing address: 0x90 in sentinelReconnectInstance -> valkeyAsyncConnectBind -> dictCreate. This matches what unstable does (no DICT_INCLUDE_DIR). Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Reverts the libvalkey portion of #3697 (0.5.0 update). The 0.5.0 update introduced a `DICT_INCLUDE_DIR` feature whose implementation is broken: `#include "dict.h"` in `async.c` and `cluster.c` resolves to libvalkey's local `dict.h` (5-field `dictType`) instead of valkey's (9-field `dictType`), causing a struct layout mismatch with the linked `dictCreate`. This crashes every sentinel instance on startup. On unstable this works by coincidence because `dict` is typedef'd to `hashtable` and the memory layout happens to have zeros at the critical offset. On 9.1 with the traditional dict implementation, it reads garbage and crashes. The fix should be done upstream in libvalkey (the `DICT_INCLUDE_DIR` feature needs to use `<dict.h>` instead of `"dict.h"`). Once that's fixed upstream, we can re-update. **Crash signature:** ``` signal 11, accessing address 0x90 sentinelReconnectInstance -> valkeyAsyncConnectBind -> dictCreate ``` Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Lift libvalkey to version 0.5.0 that includes pipelining optimizations and corrections needed for RDMA.