Skip to the content ForoHackers
Log inJoin

How ECC memory actually corrects one bit and notices two (SECDED)

Computer architectureHardware securityReliability engineering
#1115 · bitflip_betty · · Report

Cosmic rays get the credit, but bit flips also come from marginal cells, electrical noise, and plain bad luck. Server RAM handles them with ECC, and the usual scheme is SECDED: Single Error Correction, Double Error Detection.

The idea is a Hamming code with one extra parity bit. For 64 data bits, you store 8 check bits (a 72-bit word). Each check bit is the parity of a specific subset of data bits, chosen so that every bit position has a unique pattern of which checks it participates in.

On a read, the controller recomputes the checks and XORs them with the stored ones. This gives the syndrome:

  • Syndrome zero and overall parity matches: no error.
  • Syndrome non-zero and overall parity is wrong: a single bit flipped. The syndrome is the position of the bad bit, so flip it back. Correct.
  • Syndrome non-zero and overall parity is right: two bits flipped. You cannot locate them, but you know something is wrong. Report an uncorrectable error.
  • Three or more flips can fool it, which is rare.

Memory controllers also do scrubbing: they read through all of memory in the background, so a single flipped bit gets corrected and rewritten before a second one arrives in the same word. Without scrubbing, errors accumulate until two meet.

Two things people forget: ECC protects the DRAM array, not the cache, the CPU registers or your logic bugs. And a rising count of corrected errors on one DIMM is a warning, not a victory. Swap it before it becomes uncorrectable.

#1799 · legacy_cobol_whisperer · · Report

On mainframes this was normal decades ago. I remember the console logging "corrected error, DIMM 3" for weeks, and the engineer swapping the board during the quiet window without anyone noticing. Corrected errors are a free early warning if somebody reads the logs.

#1800 · cron_job_carl · · Report

On Linux, the EDAC subsystem exposes those counters (/sys/devices/system/edac/mc/), and a boring alert on "corrected errors increased since yesterday" has caught more failing DIMMs for me than any other check.

#1801 · fpga_fiddler · · Report

Same ideas apply inside FPGAs: block RAM can have ECC bits, and configuration memory gets scrubbed periodically in high-radiation designs for exactly the "two errors meet" reason. The scrub interval is chosen from the expected upset rate.

Log in or join to reply.