Skip to content

[Task] PHP: Fix memory leaks and resource management issues in C extension #175

@prateek-kumar-improving

Description

Description

The following issues in PHP will be fixed as part of this task:

  1. _initialize_open_telemetry() can throw an exception, but valkey_glide_build_client_config_base() ignores it, returning SUCCESS with a pending exception. This leaks the config and passes a bad state into the Rust FFI.

  2. execute_command_with_route() in command_response.c leaks route_bytes and route.key when parameter validation fails after route allocation.

  3. execute_sort_command() and execute_sort_ro_command() call efree() on offset_str/count_str unconditionally, but these are only allocated when a LIMIT option is present. This crashes PHP debug builds.

  4. free_valkey_glide_object() does not free buffered_commands. If the object is destroyed mid-batch (exception, scope exit), all buffered command data leaks.

  5. ValkeyGlide::close() and ValkeyGlideCluster::close() are no-ops — they return true without releasing the Rust client. Connections are only freed on garbage collection.

Checklist

No response

Additional Notes

No response

Metadata

Metadata

Labels

phpPull requests that update php code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions