Skip to content

grep/fgrep has some bad code that segfaults #5675

@guilt

Description

@guilt

Existing issues matching what you're seeing

  • I was not able to find an open or closed issue matching what I'm seeing

Git for Windows version

git version 2.49.0.windows.1
cpu: x86_64
built from commit: cca1f38702730b35f52c29efd62864b85e85ddcc
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.12.1
OpenSSL: OpenSSL 3.2.4 11 Feb 2025
zlib: 1.3.1

Windows version

Windows 11

Windows CPU architecture

x86_64 (64-bit)

Additional Windows version information

Microsoft Windows [Version 10.0.26100.4349]

Options set during installation

Editor Option: Notepad
Custom Editor Path:
Default Branch Option: main
Path Option: BashOnly
SSH Option: ExternalOpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: ConHost
Git Pull Behavior Option: FFOnly
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable FSMonitor: Disabled

Other interesting things

Here is a firsthand reproducible set of commands that anyone can run in Git Bash:

Image

This has been going for so long, I hope you actually ensure grep is up-to-date and fixed in your distribution of Git when shipping to people. There may be other outdated utilities with less than ideal code and it needs to be brought up-to-date.

The expected behavior of fgrep is to actually do case insensitive matching, so
is would still match both is and Isolated. On a Simple WSL Debian instance, you can see this.

Image

Terminal/shell

Git Bash

Commands that trigger the issue

echo 'This is a Isolated test.' | tee test.txt
fgrep is test.txt
fgrep -i is test.txt

Expected behaviour

This is what should appear for the -i command:

This is a Isolated test.

Actual behaviour

Aborted

crash. Multiple times. This can be triggered on the grep binary with -F. fgrep is just a shell wrapper to your grep.

Repository

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions