Skip to content

RipGrep musl Segfault: Quick Fix Guide (2026)

The ripgrep musl segfault bug is trending - here's how to detect if you're affected, swap to the glibc build, and keep large searches stable.

6 min readBeginner

The ripgrep musl segfault bug (issue #3494) was filed in late July 2026 and picked up serious attention on Hacker News shortly after. If you use rg on Linux – especially the version bundled inside OpenAI Codex – there’s a real chance your searches are silently crashing on big repos. This post skips the kernel-race deep dive and gives you the two fixes that actually work.

Two responses to this bug – one is clearly better

You’ll see people arguing about this online. Roughly, there are two camps:

  • Wait for a patch. The detailed analysis traces the root cause down into the Linux kernel’s per-VMA lock fast path – not ripgrep itself. So technically, nothing for ripgrep to fix.
  • Swap the binary today. Replace the musl build with a glibc build (or a distro package). Takes 30 seconds. Bug goes away.

Camp two wins. Waiting for a kernel fix to trickle down through musl, then a ripgrep release, then Codex’s bundled dependency is a long road. And glibc builds already exist. Just use one.

Are you actually affected? Check in one command

Not every rg on Linux is musl-linked. Most distro packages use glibc. Run this:

rg --version
file $(which rg)

If the output of file mentions statically linked, or if you installed rg by downloading the x86_64-unknown-linux-musl.tar.gz release tarball, you’re on the affected build. Byte-for-byte identical with the ripgrep-15.2.0-x86_64-unknown-linux-musl release tarball – that’s confirmed directly in issue #3494. Same story for Codex on Linux: turns out the rg bundled with Codex Desktop is pulled from that exact upstream musl tarball, so Codex users on Linux are silently carrying the affected binary without knowing it.

One more place to check: any bundled rg binary shipped inside a third-party tool. If you find one under ~/.local/share/ or inside an app’s own bin/ directory, run file on it – a statically linked result is the tell.

The fix: swap to the glibc build

On any mainstream Linux (Ubuntu, Debian, Fedora, Arch), your package manager already ships a glibc-linked build. That’s the cleanest fix.

# Debian / Ubuntu
sudo apt install ripgrep

# Fedora
sudo dnf install ripgrep

# Arch
sudo pacman -S ripgrep

Verify: ldd $(which rg) should now show libc.so.6 – that’s glibc. The mallocng crash path doesn’t exist there.

If your distro’s version lags behind (Debian stable ships old rg, for instance), grab the glibc release tarball directly. The naming convention matters:

# Good - glibc build, no bug
ripgrep-15.x.x-x86_64-unknown-linux-gnu.tar.gz

# Bad - this is the one that segfaults
ripgrep-15.x.x-x86_64-unknown-linux-musl.tar.gz

The keyword is gnu versus musl in the filename. Same version number, completely different linkage.

There’s also a third path that’s easy to miss: if you’re on a glibc machine with Rust installed, cargo install ripgrep builds against your system’s glibc and sidesteps the bug entirely – no musl involved at any point in the build.

What if you’re on Alpine or Void?

Then you can’t just “switch to glibc” – Alpine Linux is built on musl, and Void’s musl variant is the same story. You have three options:

  1. Build from source with cargo install ripgrep – but on Alpine this still links against your system musl, so it doesn’t help. On a separate glibc host, though, it works fine (see above).
  2. Install a glibc runtime shim. On Alpine, apk add gcompat lets you run glibc-linked binaries.
  3. Pin to an older ripgrep that predates mallocng being aggravated by this workload. Anything before 15.x is worth trying.

None of these are perfect. If you’re on Alpine specifically for containers, the more honest answer is: don’t run huge recursive searches from inside a musl container. Do that work on the host.

Real-world example: fixing it inside Codex on Linux

Here’s the actual scenario that surfaced the bug. Someone runs a long Codex session, and rg keeps quietly returning nonzero exit codes on big monorepos. Codex sees the failure and moves on – you get incomplete search results and never know why.

# Find the bundled rg (path varies by install)
find ~ -name "rg" -type f 2>/dev/null | xargs -I{} file {}

# Rename the bad one
mv /path/to/codex/bin/rg /path/to/codex/bin/rg.musl.bak

# Symlink to your distro's glibc rg
ln -s $(which rg) /path/to/codex/bin/rg

Restart Codex. The search tool now uses the glibc build. Sanity-check with a large search that used to crash – if it completes cleanly, you’re done.

Why lowering –threads is not a real workaround

You’ll see this suggested online. It doesn’t hold up. According to the dfoxfranke analysis, crashes hit roughly every 1-3 minutes on a 20 GiB, 1.8-million-file tree at --threads 12. Dropping threads reduces the frequency, but the underlying mechanism is a race on the first write to a freshly-faulted page – the interaction between the per-VMA-lock anonymous-fault fast path and a concurrent munmap’s TLB shootdown (a Linux kernel race, documented in the same analysis). Single-threaded searches avoid it because nothing’s concurrent. Anything above one thread on a big tree is still gambling.

If you must stay on the musl binary temporarily, --threads 1 is safer than --threads 4. But you also lose most of what makes ripgrep fast.

Pro tip: If you’re building your own musl-linked Rust binary and hitting similar heap corruption under concurrency, community reports on Hacker News point to swapping in mimalloc as a global allocator. One commenter reported a 20x improvement, close to what glibc offers by default. Not a fix for the ripgrep release binary itself – but useful if you’re shipping your own musl binaries.

What to do right now

Open a terminal. Run file $(which rg). If it says statically linked or you know it came from a musl tarball, run your distro’s package install command from the section above and overwrite it. Then run rg against your biggest repo. If it finishes without a 139 exit code, you’re safe – go back to whatever you were doing before this bug ate your afternoon.

FAQ

Is this bug fixed yet?

No. As of early August 2026, issue #3494 is still open, and the root cause appears to be in the Linux kernel – not something ripgrep can patch alone.

My rg is version 15.2.0 but it doesn’t crash. Am I fine?

Probably. The bug needs a large tree, concurrent threads, and the specific musl mallocng codepath. If you installed rg from apt, dnf, pacman, or Homebrew, you’re on glibc (or on macOS, which isn’t affected at all) and the crash path simply doesn’t exist in your binary. Run ldd $(which rg) – if you see libc.so.6, you can stop worrying.

Should I switch away from musl for all my Rust projects now?

That’s overreacting. musl is still the right call for static binaries and Alpine containers – most workloads are fine. The problem is narrow: mallocng under high concurrency on very-large working sets. A lot of real tools never hit that combination. What to watch for: multithreaded tools that walk big filesystems. If you’re shipping one of those, consider mimalloc or a glibc target. Otherwise, don’t change anything.