Google Publishes AI-Assisted Rust GIF Library Tested on Over 30 Million GIFs

Google says the replacement kept pace with the C version and let it remove isolation sandboxes. The difficult work was checking behavior and making the boundary with C safe.

By 3 min read
Google Publishes AI-Assisted Rust GIF Library Tested on Over 30 Million GIFs
Google Publishes AI-Assisted Rust GIF Library Tested on Over 30 Million GIFs

Listen to this story

The audio brief

About 1:29
0:001:29
Read transcript
Google has published a Rust replacement for its GIF-decoding library, and says it’s already running in production. The striking part isn’t simply that Gemini drafted the code from one prompt. It’s the verification that followed—and what that testing uncovered along the way. The original library was written in C, and existing software needed to keep calling it as before. So Google preserved the expected functions and data structures. That made the replacement compatible, but left a tricky seam: C callers pass raw memory pointers, and Rust needs clear rules for who owns that memory and how long it stays valid. Engineers had to review those rules carefully; generated code alone wasn’t enough. Google says its checks compared the two libraries on more than 30 million GIFs. A six-day fuzzing run—feeding both versions a stream of varied inputs—completed 200 million iterations without observed differences. That’s strong evidence of matching behavior, not proof that every case is safe. Testing also exposed a GIF-decompression edge case and an out-of-bounds write in an earlier patch to Google’s C code. The company reports comparable speed for the Rust and C versions. The production benefit it highlights came instead from removing image-processing sandboxes, which lowered slow, high-end response times. Google says its production nodes using the replacement were not vulnerable to a flaw later found in upstream giflib. The open question is how the public replacement will be maintained as the original library changes—and whether its C-facing memory rules remain carefully reviewed.

Story brief

3 key points

Google's giflib-rs is now a production-used, publicly published substitute for the upstream C GIF decoder, with existing C callers preserved through a compatibility layer. Its significance is less that Gemini drafted a port from one prompt than that engineers subjected it to an extended verification loop: differential tests, fuzzing, and human review caught edge cases and unsafe pointer handling. Google reports...

  1. 01

    Exported symbols and data structures preserve compatibility for existing C callers, but raw-pointer ownership and memory lifetimes required expert review.

  2. 02

    Regression checks covered more than 30 million GIFs; a six-day differential-fuzzing run completed 200 million iterations without observed functional drift, not proof of exhaustive.

  3. 03

    Testing exposed an unhandled GIF decompression edge case and an out-of-bounds write in an earlier internal patch to Google's C code.

Google has published giflib-rs, a Rust replacement for a C library that decodes GIF images. Engineers used Gemini to draft the rewrite, then tested it against the original and deployed it in production. The result, as described by InfoQ, is a case for AI-assisted migration—but not for trusting generated code without extensive checks.

A different library for the same callers

The target was giflib, an approximately 3,000-line C image-processing library. Engineers Bastian Kersting and Max Hils needed the replacement to work with existing software, not merely decode GIFs in isolation. They kept the exported symbols and data-structure definitions that callers expected, allowing the Rust version to serve as a drop-in replacement.

That compatibility created a hard boundary. Existing C callers pass raw pointers—memory addresses that Rust cannot automatically treat as safe. InfoQ describes unsound pointer handling in early iterations; human experts had to inspect and refine the rules for who owned that memory and how long it remained valid. Rewriting the library did not eliminate the need to get its interface with C right.

One prompt, then a long verification loop

Gemini produced an initial port from a single prompt. The engineers then compared the two implementations rather than treating that output as finished code. Automated differential tests ran both versions on the same inputs, and failure traces went back to the model for further fixes. Human review remained necessary at the C-to-Rust boundary.

The reported checks
More than 30 millionReal-world GIFs decoded

Google's regression checks compared rendering across more than 30 million GIF assets.

200 millionDifferential-fuzzer iterations

The reported side-by-side fuzzing run lasted six days without observed functional drift.

Those checks tested whether the new library behaved like the old one across many inputs; they were not a guarantee that every possible input had been covered. The wider verification process also exposed an unhandled edge case in GIF decompression and an out-of-bounds write in an earlier internal patch to Google's C code. Testing the replacement revealed something about the code it was meant to replace.

What changed in production

InfoQ reports that production nodes running Google's Rust replacement were not vulnerable to an out-of-bounds heap write later catalogued as CVE-2026-26740 in upstream giflib. That is a concrete result for this flaw, not proof that the replacement has no security bugs. The pointer handling at its C interface remains a reason for careful review.

Google's reported production measurements showed the Rust and C binaries running at comparable speed. After the replacement, engineers removed process-isolation sandboxes previously used to contain image-decoding work. InfoQ says that change reduced p99 tail latency—the slow end of response times. The performance gain came from removing isolation overhead, not from a reported speed advantage for Rust decoding itself.

The cost of keeping a replacement current

Publishing giflib-rs makes the replacement available beyond Google. It also leaves a maintenance question: a Rust fork can diverge when the upstream C library adds features or changes its design. InfoQ notes that the C-facing wrapper still calls for human expertise, including checks on memory lifetimes and thread safety.

Sources

  1. infoq.comGoogle Rewrites Critical C Dependencies to Rust Using AI and Differential Fuzzing

Loading discussion...

YOUR READING SPACE

Notifications