8000 Fix memory leak in RESP3 map parsing by uglide · Pull Request #204 · redis/hiredis-py · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix memory leak in RESP3 map parsing #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 9, 2025
Merged

Fix memory leak in RESP3 map parsing #204

merged 11 commits into from
May 9, 2025

Conversation

uglide
Copy link
Contributor
@uglide uglide commented Apr 24, 2025

Fix #175

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a memory leak in RESP3 map parsing by adjusting reference count management and error handling in the reader implementation. Key changes include:

  • Adding new tests to stress-test memory leak scenarios and unhashable key handling.
  • Fixing reference counting in the map parsing in src/reader.c.
  • Updating dependencies and CI workflows to support memory profiling with memray.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_reader.py New tests added for detecting memory leaks and unhashable keys.
src/reader.c Adjusted reference counts and error handling in map parsing.
dev_requirements.txt Updated test dependencies and added memray for memory profiling.
.github/workflows/integration.yaml Added steps to install memray dependencies and set environment variables.
.github/workflows/freebsd.yaml Updated pip installation to bypass memray on FreeBSD.
Comments suppressed due to low confidence (1)

src/reader.c:87

  • Consider adding error checking after the PyDict_SetItem call in the else branch (using last_key as key) to mirror the error handling in the if branch.
PyDict_SetItem(parent, last_key, obj);

Copy link
@StefanPalashev StefanPalashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, thank you @uglide!

@uglide uglide merged commit 7e77f22 into master May 9, 2025
29 checks passed
@uglide uglide deleted the issue_175 branch May 9, 2025 08:51
uglide added a commit to uglide/hiredis-py that referenced this pull request May 9, 2025
* Fix memory leak in RESP3 map parsing

Fix redis#175

* Add memray deps installation

* Install deps only on ubuntu

* Disable memray installation on Windows

* Another attempt

* Fix memray on old macOS versions

* Disable memray for PyPy

* Exclude FreeBSD

* Revert

* Another attempt for freebsd fix

* Another attempt for freebsd fix

(cherry picked from commit 7e77f22)
uglide added a commit that referenced this pull request May 9, 2025
* Fix memory leak in RESP3 map parsing (#204)

* Fix memory leak in RESP3 map parsing

Fix #175

* Add memray deps installation

* Install deps only on ubuntu

* Disable memray installation on Windows

* Another attempt

* Fix memray on old macOS versions

* Disable memray for PyPy

* Exclude FreeBSD

* Revert

* Another attempt for freebsd fix

* Another attempt for freebsd fix

(cherry picked from commit 7e77f22)

* Version 3.1.1

* Run integration workflow on version branches
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.

Memory leak on hgetall with RESP3 and hiredis
3 participants
0