The Trifecta Tech Foundation organization, known for developing projects such as ntpd-rs, sudo-rs, zlib-rs, and bzip2-rs, recently discussed Firefox’s move to utilizing the library zlib-rs, written in Rust, for compression and decompression processes using the gzip method. The transition from zlib to zlib-rs not only helped in safeguarding against memory-related errors but also significantly boosted performance. Tests revealed speedup ranging from 3.3 to 32.5 times for single decoding operations and 2.7 to 10.86 times for continuous stream decoding.
Following the integration of the zlib-rs library into the release of Firefox 151, certain users experienced a issue causing crashes due to exceeding acceptable limits. It was noted that while the Rust code resulted in a crash, a similar scenario in C would cause invisible data corruption without halting operations.
Despite initial difficulties in replicating the problem on their systems, developers eventually identified the root cause. After analyzing multiple error reports, it was concluded that the failure stemmed from a bug in the microcode of Intel CPU microarchitecture Raptor Lake 13th and 14th generation, triggered by the incorrect usage of a register.
The issue arose due to the LLVM code generator employing the “mov byte ptr [rsi + rdi + 1], ch” instruction for writing results to memory during Huffman coding. On the Raptor Lake CPU, this execution led to bits 0-7 from the CL register being written to memory instead of the intended 8-15