Skip to content

Commit fdfc418

Browse files
committed
searcher: disable mmap searching on non-64 bit
It looks like it's possible for mmap to succeed on 32-bit systems even when the full file can't be addressed in memory. This used to work prior to ripgrep 13, but (maybe) something about statically linking vcruntime has caused this to now fail. It's no big deal to disable mmap searching on 32-bit, so we just do that instead of returning incorrect results. Fixes BurntSushi#1911
1 parent 5bf7436 commit fdfc418

File tree

1 file changed

+10
-0
lines changed
  • crates/searcher/src/searcher

1 file changed

+10
-0
lines changed

crates/searcher/src/searcher/mmap.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ impl MmapChoice {
7171
if !self.is_enabled() {
7272
return None;
7373
}
74+
if !cfg!(target_pointer_width = "64") {
75+
// For 32-bit systems, it looks like mmap will succeed even if it
76+
// can't address the entire file. This seems to happen at least on
77+
// Windows, even though it uses to work prior to ripgrep 13. The
78+
// only Windows-related change in ripgrep 13, AFAIK, was statically
79+
// linking vcruntime. So maybe that's related? But I'm not sure.
80+
//
81+
// See: https://github.com/BurntSushi/ripgrep/issues/1911
82+
return None;
83+
}
7484
if cfg!(target_os = "macos") {
7585
// I guess memory maps on macOS aren't great. Should re-evaluate.
7686
return None;

0 commit comments

Comments
 (0)