A recent issue has been reported on GitHub concerning the RipGrep tool, specifically its musl binaries, which occasionally experience segmentation faults (segfaults) during very large-scale searches. According to the user’s report on the RipGrep GitHub repository, the version of ripgrep in question is 15.2.0, compiled with features like pcre2 and simd support for SSE2, SSSE3, and AVX2.
The user encountered this bug initially in the rg binary bundled with OpenAI Codex, which is identical to the one found in the official RipGrep release. The crash occurs when searching through very large file trees at a high level of concurrency on OpenSUSE Tumbleweed Linux x86_64. The error is traced back to an integrity assertion failure related to heap metadata within MUSL’s mallocng during a calloc call from opendir.
To reproduce the behavior, a Python script named generate_repro_tree.py was provided. This script generates a large tree filled with random files, mimicking the statistics of the repository where the bug was initially discovered. The tree created contains approximately 20GiB of data spread across 1.8 million files. The user then suggests running the rg command in a loop, searching for a string that doesn’t exist in the tree, which triggers the SIGSEGV error within about a minute on a system with 24 cores and sufficient RAM.
The crash results in a coredump with a detailed backtrace that implicates various system calls and Rust standard library functions, ultimately pointing to issues within the opendir system call and the subsequent handling by RipGrep’s code.
The user expects RipGrep to operate without such segmentation faults, especially during large-scale searches. This issue, if consistently reproducible, could pose significant problems for users relying on RipGrep for extensive file system searches, potentially leading to data loss or workflow disruptions. The RipGrep community and developers are likely to address this issue in upcoming releases or patches to ensure the stability and reliability of the tool.