Skip to content

Fix RedisCluster multi-key argument ownership - #2954

Open
ebubekiryigit wants to merge 3 commits into
phpredis:developfrom
ebubekiryigit:fix/cluster-key-argument-ownership
Open

ebubekiryigit wants to merge 3 commits into
phpredis:developfrom
ebubekiryigit:fix/cluster-key-argument-ownership

Conversation

@ebubekiryigit

Copy link
Copy Markdown
Contributor

RedisCluster converts MGET, DEL and UNLINK keys in caller-owned values. This can modify input arrays and references, leak converted variadic keys, and release stringable objects too early. Modifying OPcache-protected literal arrays can also crash PHP.

Convert all keys into an owned string table before sending or queueing any slot batch, and release temporary allocations on every exit path.

If conversion throws, no part of that command is dispatched and existing MULTI entries remain intact. Ordinary conversion warnings retain their behavior; warnings promoted to exceptions now abort before dispatch. Successful command results, prefix handling and slot routing are unchanged.

Regression tests cover shared arrays, references, stringable object lifetime, integer-key allocations, prefixes, empty arrays, and conversion failures after keys from different slots.

Validation:

  • Redis, RedisArray, RedisCluster and RedisSentinel suites passed on PHP 8.5 / Redis 8.8.
  • Focused Valgrind checks reported no errors or leaks.
  • The protected OPcache reproduction crashes on current develop and passes with this fix.

Convert borrowed key arguments into owned strings without modifying callers. Release temporary keys and handle conversion exceptions before dispatch.

Add regressions for shared arrays, stringable arguments, integer-key allocations, prefixes and conversion failures.
Normalize array and variadic keys into an owned string table before
sending or queueing any slot batch. Conversion errors can no longer leave
partially executed deletes or dangling MULTI reply contexts.

Add regressions for cross-slot conversion errors, warning behavior, empty
arrays, and caller-owned references.
Capture both E_NOTICE and E_WARNING when checking array-key coercion.
PHP 7.4 emits a notice, while PHP 8 emits a warning.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant