A hang that starts at connection 1,024
Redis published patch releases on all of its maintained lines on December 4, 2026: 8.12.1, 8.10.4, 8.8.5, 8.6.9, 8.4.9 and 8.2.12. Each release note carries the same entry, marked with high upgrade urgency for 8.12.1: with TLS enabled, clients could hang in the TLS handshake, and stay in CLIENT LIST, once the server had more than 1,024 connections, due to an out-of-bounds read in the event loop. The fix is pull request 16307, merged on November 26.
The bug is worth understanding even for teams that will simply upgrade, because its symptoms look like a network or client problem, it depends on file descriptor numbers rather than on load, and the mechanism, a lazily grown array checked against the wrong bound, recurs in many systems. This article is a reading of the pull request and the 8.12.1 source. I did not build or run Redis for it, so nothing below is a measurement of a Redis server.
The event array grows lazily
Redis's event loop, ae.c, keeps an array of file event records indexed by file descriptor. Two numbers describe it. setsize is the maximum number of descriptors the loop may handle, derived from the client limit. nevents is the number of records actually allocated. Since the asynchronous I/O threads work merged in December 2024 as pull request 13695, the loop allocates only INITIAL_EVENT, 1,024 records, at creation, or fewer if setsize is smaller. When aeCreateFileEvent registers a descriptor at or beyond nevents, it grows the array to the larger of double the current size and the descriptor plus one, capped at setsize, and marks the new records as having no events.
Three accessors kept the old bound. aeGetFileEvents, aeGetFileClientData and aeDeleteFileEvent checked the descriptor against setsize, not nevents. For a descriptor that had never been registered and lay in the range from nevents up to setsize, they read the record at that index, which is past the end of the allocated array.
Why only TLS, and why at 1,024
Plain TCP connections register their read event directly, through aeCreateFileEvent, which grows the array first. The TLS connection type asks for the current event mask before registering anything: when a client is created, the TLS read-handler setup calls updateSSLEvent, which calls aeGetFileEvents on the new descriptor. For the first TLS client accepted on a descriptor equal to nevents, that read returns whatever bytes follow the array instead of "no events".
The pull request describes the consequences. If the stray value has the readable bit set, the code believes the read event already exists and never creates it. The server then never reads from that client, so the client hangs in the TLS handshake. The connection stays in CLIENT LIST with no command and zero bytes received, even after the peer goes away, because its descriptor is never polled. And because no event was created, the array is not grown, so later descriptors can be affected in the same way. Each I/O thread has its own event loop and array, so each is affected independently. Module APIs that add or remove events use the same accessors.
The descriptors at risk follow from the growth rule. Starting at 1,024 records, the first unregistered access at descriptor 1,024 is out of bounds. If the array does grow to 2,048, the next boundary is descriptor 2,048, then 4,096. The author's reproduction matches: with 4,300 TLS connections opened one at a time on an unpatched build, two or three never got a reply, and CLIENT LIST showed them at fd=1024 and fd=4096. Under AddressSanitizer the read is reported deterministically as a heap buffer overflow.
| Event | Records allocated | Descriptor at the boundary |
|---|---|---|
| Loop created with a large client limit | 1,024 | 1,024 |
| A descriptor at 1,024 registers normally | 2,048 | 2,048 |
| A descriptor at 2,048 registers normally | 4,096 | 4,096 |
The table is an arithmetic model of the doubling rule, not observed allocation sizes from a server. Whether a given boundary descriptor hangs depends on what happens to be in memory after the array, which is why the bug appeared as "a few clients blocked forever" rather than as a failure at every boundary.
The fix
The patch changes the bound in the three accessors from setsize to nevents, with a comment explaining that the array is grown lazily so a never-registered descriptor can be within setsize but beyond the array. Since nevents never exceeds setsize, the old check is implied by the new one. A unit test creates a loop with room for 2,048 descriptors, queries and deletes descriptor 1,024 before it is registered, and asserts that the answers are "no events" and "no client data" and that the array did not change. The author reports no hung clients with 4,300 and 9,000 connections, also with four I/O threads and on 8.6.8, after the fix.
Do you need to act
The conditions are TLS enabled on client connections and descriptor numbers reaching 1,024 in an event loop. A server whose clients connect over plain TCP is not affected by this path. A server with TLS that never exceeds roughly a thousand open descriptors per loop will not reach the first boundary; remember that descriptors include listening sockets, replication links and files, not only clients. The pull request states that the code is the same from 8.0 to the current development branch.
To check a running TLS server for the symptom, look in CLIENT LIST for entries whose fd is 1,024, 2,048 or 4,096 with cmd=NULL, tot-net-in=0 and an age that keeps growing:
redis-cli --tls ... CLIENT LIST | grep -E 'fd=(1024|2048|4096) ' | grep 'tot-net-in=0'An empty result does not prove the bug is absent; a stray value without the readable bit set produces no hang. A match on a long-lived entry with no input is strong evidence.
Upgrade notes
- Upgrade TLS-enabled servers to the patch release of their line: 8.12.1, 8.10.4, 8.8.5, 8.6.9, 8.4.9 or 8.2.12.
- Until then, a client-side connect and handshake timeout turns a silent hang into a retry on a new connection, which will usually receive a different descriptor.
- Connection pooling with a bounded pool size keeps descriptor counts lower than one connection per request, and reduces exposure on servers near the boundary.
- After upgrading, recheck
CLIENT LISTfor idle entries with no input; existing stuck entries do not disappear until the connection is closed.
The general lesson
A container that grows lazily has two sizes, capacity reserved and capacity allocated, and every accessor must check the one that describes memory. Code that predates the lazy growth naturally checks the old bound, and tests that never cross the initial allocation pass. Boundary tests at exactly the initial size, as the new Redis unit test does, catch this class of bug cheaply. A second lesson is about call order: the TLS path read state before creating it, and that ordering is what exposed the uninitialised read.
Verification
- After upgrading, open more than 1,024 TLS connections in a staging server and confirm every one answers a
PING. - Track the count of client entries with no input and growing age, as a standing alert.
- In your own code, add a test that reads state for an index equal to the initial allocation of any lazily grown table.
The companion example contains a Python model of the growth rule and the old and new bounds checks, with tests that reproduce which descriptors are read out of bounds.