# git log --graph --no-graph can cause segfault

3 messages from 2025-02-08 to 2025-02-08. Participants: Emily Klassen, Đoàn Trần Công Danh.
Thread: https://gitlist.dev/t/62922

## Emily Klassen, 2025-02-08 03:34

Subject: git log --graph --no-graph can cause segfault
Message-ID: <CADY4h_qagYhSP2kz=zNSjfskN1ODxLf1DjEME6BdYw6j-JEAhA@mail.gmail.com>
URL: https://gitlist.dev/e/CADY4h_qagYhSP2kz%3DzNSjfskN1ODxLf1DjEME6BdYw6j-JEAhA%40mail.gmail.com

```
> What did you do before the bug happened? (Steps to reproduce your issue)

$ git config --get alias.l
log --pretty=oneline --abbrev-commit --decorate --graph

$ git --no-pager l --reverse --no-graph --name-status
e83c516331 Initial revision of "git", the information manager from hell
error: git died of signal 11

> What did you expect to happen? (Expected behavior)

I expect the commit listing to display successfully.

> What happened instead? (Actual behavior)

Git seems to have crashed. My best guess is that some state gets set with the
first `--graph` flag which is not cleared with the `--no-graph` flag.

> What's different between what you expected and what actually happened?

Git crashed.

> Anything else you want to add:

I also tried to manually expand the alias with

$ git --no-pager log --pretty=oneline --abbrev-commit --decorate
--graph HEAD --reverse --no-graph --name-status
e83c516331 Initial revision of "git", the information manager from hell

$ echo $?
139

Which indicates a segfault.

The below command works properly

$ git log --pretty=oneline --abbrev-commit --decorate HEAD --reverse
--name-status

but obviously, the intent is to be able to use my `l` alias with the
`--reverse` flag by disabling `--graph`. My workaround is to create a `lr`
alias which replaces `--graph` with `--reverse`.

I also tested "git log --graph --no-graph --name-only" and "--patch"
and "--name-status", and all of those failed, without even specifying
"--reverse"

Also verified by building `git` from the `next` branch.

> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.48.1
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
libcurl: 8.7.1
zlib: 1.2.12
uname: Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16
PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64
compiler info: clang: 16.0.0 (clang-1600.0.26.6)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh


[Enabled Hooks]

~ Emily Marigold Klassen

```

## Đoàn Trần Công Danh, 2025-02-08 04:44

Subject: Re: git log --graph --no-graph can cause segfault
Message-ID: <Z6bhS7THkV2ovXfQ@danh.dev>
URL: https://gitlist.dev/e/Z6bhS7THkV2ovXfQ%40danh.dev
In-Reply-To: <CADY4h_qagYhSP2kz=zNSjfskN1ODxLf1DjEME6BdYw6j-JEAhA@mail.gmail.com>

```
On 2025-02-07 19:34:11-0800, Emily Klassen <forivall@gmail.com> wrote:
> > What did you do before the bug happened? (Steps to reproduce your issue)
> 
> $ git config --get alias.l
> log --pretty=oneline --abbrev-commit --decorate --graph
> 
> $ git --no-pager l --reverse --no-graph --name-status
> e83c516331 Initial revision of "git", the information manager from hell
> error: git died of signal 11
> 
> > What did you expect to happen? (Expected behavior)
> 
> I expect the commit listing to display successfully.
> 
> > What happened instead? (Actual behavior)
> 
> Git seems to have crashed. My best guess is that some state gets set with the
> first `--graph` flag which is not cleared with the `--no-graph` flag.
> 
> > What's different between what you expected and what actually happened?
> 
> Git crashed.

Given commands yields: "fatal: Out of memory, realloc failed" in my
system. But it's fixed by jk/combine-diff-cleanup, which is merged
into master.

Would you try to run from master branch to see if your problem has
been fixed?

-- 
Danh

```

## Emily Klassen, 2025-02-08 05:51

Subject: Re: git log --graph --no-graph can cause segfault
Message-ID: <CADY4h_rOxG3eMR46SCL2Db4L6+++Tt5Ky6w5R8PPgofC+0iFxg@mail.gmail.com>
URL: https://gitlist.dev/e/CADY4h_rOxG3eMR46SCL2Db4L6%2B%2B%2BTt5Ky6w5R8PPgofC%2B0iFxg%40mail.gmail.com
In-Reply-To: <Z6bhS7THkV2ovXfQ@danh.dev>

```
Yup, I built on `next` and it's still resulting in the segfault.
However, I did end up figuring out the issue, and I'm sending a proper
patch momentarily. Basically "revs->diffopt.output_prefix_data" needs
to be nulled in the "--no-graph" argument parser in revision.c

~ Emily Marigold Klassen




On Fri, Feb 7, 2025 at 8:45 PM Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:
>
> On 2025-02-07 19:34:11-0800, Emily Klassen <forivall@gmail.com> wrote:
> > > What did you do before the bug happened? (Steps to reproduce your issue)
> >
> > $ git config --get alias.l
> > log --pretty=oneline --abbrev-commit --decorate --graph
> >
> > $ git --no-pager l --reverse --no-graph --name-status
> > e83c516331 Initial revision of "git", the information manager from hell
> > error: git died of signal 11
> >
> > > What did you expect to happen? (Expected behavior)
> >
> > I expect the commit listing to display successfully.
> >
> > > What happened instead? (Actual behavior)
> >
> > Git seems to have crashed. My best guess is that some state gets set with the
> > first `--graph` flag which is not cleared with the `--no-graph` flag.
> >
> > > What's different between what you expected and what actually happened?
> >
> > Git crashed.
>
> Given commands yields: "fatal: Out of memory, realloc failed" in my
> system. But it's fixed by jk/combine-diff-cleanup, which is merged
> into master.
>
> Would you try to run from master branch to see if your problem has
> been fixed?
>
> --
> Danh

```
