Skip to content

Fix race condition in RESP3 parser buffer purge#3972

Merged
petyaslavova merged 2 commits intops_integrate_hitless_scenario_tests_with_scneario_runs_repofrom
copilot/sub-pr-3971
Feb 20, 2026
Merged

Fix race condition in RESP3 parser buffer purge#3972
petyaslavova merged 2 commits intops_integrate_hitless_scenario_tests_with_scneario_runs_repofrom
copilot/sub-pr-3971

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

self._buffer can be set to None by another thread between the None check and the purge() call, causing an unhandled AttributeError in the else branch of read_response.

Changes

  • redis/_parsers/resp3.py: Combine the self._buffer is not None guard with a try/except AttributeError to handle the TOCTOU race condition — consistent with the existing pattern on lines 32 and 38:
# Before
try:
    self._buffer.purge()
except AttributeError:
    pass

# After
if self._buffer is not None:
    try:
        self._buffer.purge()
    except AttributeError:
        # Buffer may have been set to None by another thread after
        # the check above; result is still valid so we don't raise
        pass

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…condition

Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>
@jit-ci
Copy link
Copy Markdown

jit-ci bot commented Feb 20, 2026

❌ Jit Scanner failed - Our team is investigating

Jit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions.


💡 Need to bypass this check? Comment @sera bypass to override.

Copilot AI changed the title [WIP] WIP address feedback on error handling and logging improvements Fix race condition in RESP3 parser buffer purge Feb 20, 2026
Copilot AI requested a review from petyaslavova February 20, 2026 12:20
@petyaslavova petyaslavova marked this pull request as ready for review February 20, 2026 12:22
@petyaslavova
Copy link
Copy Markdown
Collaborator

@sera bypass

@petyaslavova petyaslavova merged commit fbf69d8 into ps_integrate_hitless_scenario_tests_with_scneario_runs_repo Feb 20, 2026
2 checks passed
@petyaslavova petyaslavova deleted the copilot/sub-pr-3971 branch February 20, 2026 12:25
petyaslavova added a commit that referenced this pull request Feb 20, 2026
…n. Enabling troubleshooting logging for maint notifications e2e tests. (#3971)

* Fixing error handling of connection buffer purging of closed connection. Enabling troubleshooting logging for maint notifications e2e tests.

* Fix race condition in RESP3 parser buffer purge (#3972)

* Initial plan

* Combine None check with try-except for buffer.purge() to handle race condition

Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>
@petyaslavova petyaslavova added maintenance Maintenance (CI, Releases, etc) labels Feb 20, 2026
petyaslavova added a commit that referenced this pull request Feb 25, 2026
…n. Enabling troubleshooting logging for maint notifications e2e tests. (#3971)

* Fixing error handling of connection buffer purging of closed connection. Enabling troubleshooting logging for maint notifications e2e tests.

* Fix race condition in RESP3 parser buffer purge (#3972)

* Initial plan

* Combine None check with try-except for buffer.purge() to handle race condition

Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: petyaslavova <194077574+petyaslavova@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants