HeadlinesBriefing favicon HeadlinesBriefing.com

Redis Client Use-After-Free Bug Uncovered

Hacker News •
×

An unexpected use‑after‑free in the hiredis C extension of the Redis gem upgrade broke the test suite, turning several previously stable tests flaky. The issue surfaced when neighbor engineers noticed a build failure on an idle Tuesday, prompting David to pull the Andon Cord and isolate the problematic tests.

The team combed through recent PRs and found no obvious changes, except the gem upgrade. They added logging around Action Cable and Redis and discovered that the `subscribe` command reached Action Cable but never hit Redis, hinting at a race condition. A later core dump revealed a double free inside `memmove`, with a size of 45 petabytes—an impossible value that confirmed a memory‑corruption bug in the new gem.

Using an ASAN‑enabled Ruby build, Rian reproduced the crash in minutes and identified the use‑after‑free caused byਾਮ the reader thread freeing the writer buffer. Fixing the issue was straightforward: disable the C extension for Redis in all environments and submit a reproducible test case upstream.

The episode underscores the value of core‑dump analysis, dedicated tooling, and cross‑functional teamwork in diagnosing elusive memory bugs.