[2.10] Fix Fork GC potential double-free on error path - [MOD-12521]#7461
[2.10] Fix Fork GC potential double-free on error path - [MOD-12521]#7461
Conversation
* 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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.10 #7461 +/- ##
==========================================
+ Coverage 89.29% 89.30% +0.01%
==========================================
Files 207 207
Lines 35335 35448 +113
==========================================
+ Hits 31553 31658 +105
- Misses 3782 3790 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // just exit, do not abort(), which will trigger a watchdog on RLEC, causing adverse effects | ||
| RedisModule_Log(fgc->ctx, "warning", "GC fork: broken pipe, exiting"); | ||
| exit(1); | ||
| RedisModule_ExitFromChild(EXIT_FAILURE); |
There was a problem hiding this comment.
In 8.x we already had RedisModule_ExitFromChild ?
There was a problem hiding this comment.
Yes. Not sure why we didn't BP it
| // The GC should have failed, so no bytes should be collected | ||
| // (or at least the operation should complete without crashing) | ||
| ASSERT_EQ(0, fgc->stats.totalCollected); | ||
| } |
There was a problem hiding this comment.
Why not add the test simulating killing the child at different times?
There was a problem hiding this comment.
I can add it back (probably), I think it was too slow because of the exit(1), but now it should be fine
…7461) * Fix Fork GC potential double-free on error path - [MOD-12521] (#7423) * 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) * reuse one thread * improvement * remove harsh stress test * fix potential double close * exit from child with RedisModule_ExitFromChild * add heavy test back
Description
Backport of #7423 to
2.10.Note
Improves ForkGC pipe I/O error handling and buffer receive logic to avoid double-frees and adds tests that simulate pipe failures during GC and apply.
exit(1)withRedisModule_ExitFromChild(EXIT_FAILURE)on child write failure.FGC_recvFixedpolling/error handling: capturepoll_rc, break on non-EINTR read errors, and log detailedrevents/errno diagnostics.FGC_recvBufferto use a temp length, allocate into a local buffer, handleSIZE_MAX/zero-length cases safely, and avoid freeing wrong pointers on failure.fieldName = NULL).testPipeErrorDuringGCandtestPipeErrorDuringApply, including a closer thread to close pipe mid-apply; verify no crashes and no double-free (e.g.,totalCollectedunchanged).<thread>for new concurrency test support.Written by Cursor Bugbot for commit c41f9ee. This will update automatically on new commits. Configure here.