Skip to content

[2.8] Fix Fork GC potential double-free on error path - [MOD-12521]#7462

Merged
GuyAv46 merged 5 commits into2.8from
backport-7423-to-2.8
Nov 24, 2025
Merged

[2.8] Fix Fork GC potential double-free on error path - [MOD-12521]#7462
GuyAv46 merged 5 commits into2.8from
backport-7423-to-2.8

Conversation

@GuyAv46
Copy link
Collaborator

@GuyAv46 GuyAv46 commented Nov 21, 2025

Description

Backport of #7423 to 2.8.


Note

Improves Fork GC pipe read/write error handling and memory safety, and adds tests that simulate pipe failures during GC/apply.

  • Core (src/fork_gc.c)
    • FGC_sendFixed: use fgc->ctx for logging and exit via RedisModule_ExitFromChild on broken pipe.
    • FGC_recvFixed: robust poll/read loop with explicit poll_rc handling and detailed diagnostics (errno, revents).
    • FGC_recvBuffer: refactor to use a temporary length and buffer; fix allocation/free paths to avoid double-free and correctly set out params.
    • Minor safety/cleanup: initialize fieldName to NULL; remove unused pre-fork PID.
  • Tests (tests/cpptests/test_cpp_forkgc.cpp)
    • Add testPipeErrorDuringGC and testPipeErrorDuringApply to simulate pipe closures/errors and verify graceful handling without crashes or double-frees.

Written by Cursor Bugbot for commit 2419517. This will update automatically on new commits. Configure here.

* make FGC_recvBuffer clean

* add revents to timeout log

* improve polling logs

* Nullify tag field name

* remove unused variable

* add a test

* add a stres unit-test

* improve test

* improve logging

* add include

(cherry picked from commit 442a75e)
@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.53%. Comparing base (760a307) to head (2419517).
⚠️ Report is 4 commits behind head on 2.8.

Files with missing lines Patch % Lines
src/fork_gc.c 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              2.8    #7462      +/-   ##
==========================================
+ Coverage   87.49%   87.53%   +0.03%     
==========================================
  Files         203      203              
  Lines       34812    34925     +113     
==========================================
+ Hits        30458    30570     +112     
- Misses       4354     4355       +1     
Flag Coverage Δ
flow 81.89% <57.14%> (-0.20%) ⬇️
unit 42.38% <95.23%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GuyAv46 GuyAv46 added this pull request to the merge queue Nov 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 24, 2025
@GuyAv46 GuyAv46 added this pull request to the merge queue Nov 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 24, 2025
@GuyAv46 GuyAv46 added this pull request to the merge queue Nov 24, 2025
Merged via the queue into 2.8 with commit 29c9815 Nov 24, 2025
13 checks passed
@GuyAv46 GuyAv46 deleted the backport-7423-to-2.8 branch November 24, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants