# [BUG] Segfault in "git submodule"

7 messages from 2018-09-29 to 2018-10-02. Participants: Raymond Jennings, Ævar Arnfjörð Bjarmason, Duy Nguyen, Stefan Beller.
Thread: https://gitlist.dev/t/49457

## Raymond Jennings, 2018-09-29 15:22

Subject: [BUG] Segfault in "git submodule"
Message-ID: <CAGDaZ_oBpLxD0cutrsNsFBEtH+-Fn2eT40gDsnGZhhU0qm2Ofw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGDaZ_oBpLxD0cutrsNsFBEtH%2B-Fn2eT40gDsnGZhhU0qm2Ofw%40mail.gmail.com

```
[New LWP 19644]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `git submodule--helper status'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  refs_read_raw_ref (type=<optimized out>, referent=<optimized out>,
oid=<optimized out>, refname=<optimized out>, ref_store=<optimized
out>) at refs.c:1451
1451 return ref_store->be->read_raw_ref(ref_store, refname, oid,
referent, type);
#0  refs_read_raw_ref (type=<optimized out>, referent=<optimized out>,
oid=<optimized out>, refname=<optimized out>, ref_store=<optimized
out>) at refs.c:1451
#1  refs_resolve_ref_unsafe (refs=0x0,
refname=refname@entry=0x55e863062253 "HEAD",
resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493
#2  0x000055e862fcad5c in refs_read_ref_full (flags=0x7ffdc834b1bc,
oid=0x7ffdc834b1c0, resolve_flags=1, refname=0x55e863062253 "HEAD",
refs=<optimized out>) at refs.c:224
#3  refs_head_ref (refs=<optimized out>, fn=fn@entry=0x55e862f25fb0
<handle_submodule_head_ref>, cb_data=cb_data@entry=0x7ffdc834b300) at
refs.c:1314
#4  0x000055e862f292a2 in status_submodule (flags=0, prefix=<optimized
out>, ce_flags=0, ce_oid=0x55e86468d4d4, path=0x55e86468d4e8
"lpc-doc") at builtin/submodule--helper.c:624
#5  status_submodule_cb (cb_data=0x7ffdc834b240,
list_item=0x55e86468d490) at builtin/submodule--helper.c:665
#6  for_each_listed_submodule (cb_data=<optimized out>, fn=<optimized
out>, list=<optimized out>) at builtin/submodule--helper.c:404
#7  module_status (argc=<optimized out>, argv=<optimized out>,
prefix=<optimized out>) at builtin/submodule--helper.c:698
#8  0x000055e862eaec95 in run_builtin (argv=<optimized out>,
argc=<optimized out>, p=<optimized out>) at git.c:346
#9  handle_builtin (argc=<optimized out>, argv=<optimized out>) at git.c:554
#10 0x000055e862eaf985 in run_argv (argv=0x7ffdc834be20,
argcp=0x7ffdc834be2c) at git.c:606
#11 cmd_main (argc=<optimized out>, argv=<optimized out>) at git.c:683
#12 0x000055e862eae96a in main (argc=3, argv=0x7ffdc834c078) at common-main.c:43

```

## Ævar Arnfjörð Bjarmason, 2018-09-29 15:29

Subject: Re: [BUG] Segfault in "git submodule"
Message-ID: <87bm8giapu.fsf@evledraar.gmail.com>
URL: https://gitlist.dev/e/87bm8giapu.fsf%40evledraar.gmail.com
In-Reply-To: <CAGDaZ_oBpLxD0cutrsNsFBEtH+-Fn2eT40gDsnGZhhU0qm2Ofw@mail.gmail.com>

```

On Sat, Sep 29 2018, Raymond Jennings wrote:

> [New LWP 19644]
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> Core was generated by `git submodule--helper status'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0  refs_read_raw_ref (type=<optimized out>, referent=<optimized out>,
> oid=<optimized out>, refname=<optimized out>, ref_store=<optimized
> out>) at refs.c:1451
> 1451 return ref_store->be->read_raw_ref(ref_store, refname, oid,
> referent, type);
> #0  refs_read_raw_ref (type=<optimized out>, referent=<optimized out>,
> oid=<optimized out>, refname=<optimized out>, ref_store=<optimized
> out>) at refs.c:1451
> #1  refs_resolve_ref_unsafe (refs=0x0,
> refname=refname@entry=0x55e863062253 "HEAD",
> resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
> flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493
> #2  0x000055e862fcad5c in refs_read_ref_full (flags=0x7ffdc834b1bc,
> oid=0x7ffdc834b1c0, resolve_flags=1, refname=0x55e863062253 "HEAD",
> refs=<optimized out>) at refs.c:224
> #3  refs_head_ref (refs=<optimized out>, fn=fn@entry=0x55e862f25fb0
> <handle_submodule_head_ref>, cb_data=cb_data@entry=0x7ffdc834b300) at
> refs.c:1314
> #4  0x000055e862f292a2 in status_submodule (flags=0, prefix=<optimized
> out>, ce_flags=0, ce_oid=0x55e86468d4d4, path=0x55e86468d4e8
> "lpc-doc") at builtin/submodule--helper.c:624
> #5  status_submodule_cb (cb_data=0x7ffdc834b240,
> list_item=0x55e86468d490) at builtin/submodule--helper.c:665
> #6  for_each_listed_submodule (cb_data=<optimized out>, fn=<optimized
> out>, list=<optimized out>) at builtin/submodule--helper.c:404
> #7  module_status (argc=<optimized out>, argv=<optimized out>,
> prefix=<optimized out>) at builtin/submodule--helper.c:698
> #8  0x000055e862eaec95 in run_builtin (argv=<optimized out>,
> argc=<optimized out>, p=<optimized out>) at git.c:346
> #9  handle_builtin (argc=<optimized out>, argv=<optimized out>) at git.c:554
> #10 0x000055e862eaf985 in run_argv (argv=0x7ffdc834be20,
> argcp=0x7ffdc834be2c) at git.c:606
> #11 cmd_main (argc=<optimized out>, argv=<optimized out>) at git.c:683
> #12 0x000055e862eae96a in main (argc=3, argv=0x7ffdc834c078) at common-main.c:43

Can you consistently reproduce this? Maybe Stefan can make some sense of
this, but it would be really useful if you could compile git from the
master branch with CFLAGS="-O0 -g" and run gdb with that and paste that
backtrace, and even better if you're in a position to share a copy of
the repository where this happens.

```

## Duy Nguyen, 2018-09-29 15:33

Subject: Re: [BUG] Segfault in "git submodule"
Message-ID: <CACsJy8BYr6cVtAcDO9w-tfgEiWnbvQCgSR7p3OFKbqVkPA1Gaw@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8BYr6cVtAcDO9w-tfgEiWnbvQCgSR7p3OFKbqVkPA1Gaw%40mail.gmail.com
In-Reply-To: <87bm8giapu.fsf@evledraar.gmail.com>

```
On Sat, Sep 29, 2018 at 5:31 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> > #1  refs_resolve_ref_unsafe (refs=0x0,
> > refname=refname@entry=0x55e863062253 "HEAD",
> > resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
> > flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493

refs is NULL. It looks like somebody fails to get the right submodule
ref store (or tries to get it but fails to check if it may return
NULL)
-- 
Duy

```

## Raymond Jennings, 2018-09-29 16:43

Subject: Re: [BUG] Segfault in "git submodule"
Message-ID: <CAGDaZ_oS4bjzd67T5atJrJ6_x2Cfr8JgnoGWePzA53mb2ObdNg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGDaZ_oS4bjzd67T5atJrJ6_x2Cfr8JgnoGWePzA53mb2ObdNg%40mail.gmail.com
In-Reply-To: <CACsJy8BYr6cVtAcDO9w-tfgEiWnbvQCgSR7p3OFKbqVkPA1Gaw@mail.gmail.com>

```
I have a repo, but it appears to be specific to staging area state.
It only segfaults when I have a certain file deleted.

Where do you want me to upload it?
On Sat, Sep 29, 2018 at 8:34 AM Duy Nguyen <pclouds@gmail.com> wrote:
>
> On Sat, Sep 29, 2018 at 5:31 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
> > > #1  refs_resolve_ref_unsafe (refs=0x0,
> > > refname=refname@entry=0x55e863062253 "HEAD",
> > > resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
> > > flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493
>
> refs is NULL. It looks like somebody fails to get the right submodule
> ref store (or tries to get it but fails to check if it may return
> NULL)
> --
> Duy

```

## Stefan Beller, 2018-10-01 19:19

Subject: Re: [BUG] Segfault in "git submodule"
Message-ID: <CAGZ79kYX3ZgmE3S-2cq0F_27Ctq_wwuSo53znRrBquik3ODXew@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kYX3ZgmE3S-2cq0F_27Ctq_wwuSo53znRrBquik3ODXew%40mail.gmail.com
In-Reply-To: <CAGDaZ_oS4bjzd67T5atJrJ6_x2Cfr8JgnoGWePzA53mb2ObdNg@mail.gmail.com>

```
On Sat, Sep 29, 2018 at 9:43 AM Raymond Jennings <shentino@gmail.com> wrote:
>
> I have a repo, but it appears to be specific to staging area state.
> It only segfaults when I have a certain file deleted.
>
> Where do you want me to upload it?
> On Sat, Sep 29, 2018 at 8:34 AM Duy Nguyen <pclouds@gmail.com> wrote:
> >
> > On Sat, Sep 29, 2018 at 5:31 PM Ævar Arnfjörð Bjarmason
> > <avarab@gmail.com> wrote:
> > > > #1  refs_resolve_ref_unsafe (refs=0x0,
> > > > refname=refname@entry=0x55e863062253 "HEAD",
> > > > resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
> > > > flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493
> >
> > refs is NULL. It looks like somebody fails to get the right submodule
> > ref store (or tries to get it but fails to check if it may return
> > NULL)

This is spot on.

Raymond, are you on Git v2.16.0 by any chance?
(and if now which version are you on).

I suspect 2.16, as that is a version of Git, in which there happens to be
a call into the refs subsystem in submodule--helper.c in line 624.

Is it possible to upgrade Git (to v2.18.0 or later) or cherry-pick
74b6bda32f (submodule: check for NULL return of get_submodule_ref_store(),
2018-03-28) into your copy of Git?

Thanks,
Stefan

```

## Raymond Jennings, 2018-10-01 21:31

Subject: Re: [BUG] Segfault in "git submodule"
Message-ID: <CAGDaZ_q30GPWsd-NF1OSOx8m7LwXm4vk_5XcqRD5MxcjDx=GzQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGDaZ_q30GPWsd-NF1OSOx8m7LwXm4vk_5XcqRD5MxcjDx%3DGzQ%40mail.gmail.com
In-Reply-To: <CAGZ79kYX3ZgmE3S-2cq0F_27Ctq_wwuSo53znRrBquik3ODXew@mail.gmail.com>

```
Yes, git 2.16.4 to be exact.

I upgraded to 2.19 after ~arch keywording the package on gentoo and
that fixed it.
On Mon, Oct 1, 2018 at 12:19 PM Stefan Beller <sbeller@google.com> wrote:
>
> On Sat, Sep 29, 2018 at 9:43 AM Raymond Jennings <shentino@gmail.com> wrote:
> >
> > I have a repo, but it appears to be specific to staging area state.
> > It only segfaults when I have a certain file deleted.
> >
> > Where do you want me to upload it?
> > On Sat, Sep 29, 2018 at 8:34 AM Duy Nguyen <pclouds@gmail.com> wrote:
> > >
> > > On Sat, Sep 29, 2018 at 5:31 PM Ævar Arnfjörð Bjarmason
> > > <avarab@gmail.com> wrote:
> > > > > #1  refs_resolve_ref_unsafe (refs=0x0,
> > > > > refname=refname@entry=0x55e863062253 "HEAD",
> > > > > resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
> > > > > flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493
> > >
> > > refs is NULL. It looks like somebody fails to get the right submodule
> > > ref store (or tries to get it but fails to check if it may return
> > > NULL)
>
> This is spot on.
>
> Raymond, are you on Git v2.16.0 by any chance?
> (and if now which version are you on).
>
> I suspect 2.16, as that is a version of Git, in which there happens to be
> a call into the refs subsystem in submodule--helper.c in line 624.
>
> Is it possible to upgrade Git (to v2.18.0 or later) or cherry-pick
> 74b6bda32f (submodule: check for NULL return of get_submodule_ref_store(),
> 2018-03-28) into your copy of Git?
>
> Thanks,
> Stefan

```

## Raymond Jennings, 2018-10-02 04:10

Subject: Re: [BUG] Segfault in "git submodule"
Message-ID: <CAGDaZ_q6pWXHajAs+Mp5+skatx6GwiXhpTfbDF+7nXHzfmzJ-Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAGDaZ_q6pWXHajAs%2BMp5%2Bskatx6GwiXhpTfbDF%2B7nXHzfmzJ-Q%40mail.gmail.com
In-Reply-To: <CAGDaZ_q30GPWsd-NF1OSOx8m7LwXm4vk_5XcqRD5MxcjDx=GzQ@mail.gmail.com>

```
I instructed downstream to update their repository.
On Mon, Oct 1, 2018 at 2:31 PM Raymond Jennings <shentino@gmail.com> wrote:
>
> Yes, git 2.16.4 to be exact.
>
> I upgraded to 2.19 after ~arch keywording the package on gentoo and
> that fixed it.
> On Mon, Oct 1, 2018 at 12:19 PM Stefan Beller <sbeller@google.com> wrote:
> >
> > On Sat, Sep 29, 2018 at 9:43 AM Raymond Jennings <shentino@gmail.com> wrote:
> > >
> > > I have a repo, but it appears to be specific to staging area state.
> > > It only segfaults when I have a certain file deleted.
> > >
> > > Where do you want me to upload it?
> > > On Sat, Sep 29, 2018 at 8:34 AM Duy Nguyen <pclouds@gmail.com> wrote:
> > > >
> > > > On Sat, Sep 29, 2018 at 5:31 PM Ævar Arnfjörð Bjarmason
> > > > <avarab@gmail.com> wrote:
> > > > > > #1  refs_resolve_ref_unsafe (refs=0x0,
> > > > > > refname=refname@entry=0x55e863062253 "HEAD",
> > > > > > resolve_flags=resolve_flags@entry=1, oid=oid@entry=0x7ffdc834b1c0,
> > > > > > flags=flags@entry=0x7ffdc834b1bc) at refs.c:1493
> > > >
> > > > refs is NULL. It looks like somebody fails to get the right submodule
> > > > ref store (or tries to get it but fails to check if it may return
> > > > NULL)
> >
> > This is spot on.
> >
> > Raymond, are you on Git v2.16.0 by any chance?
> > (and if now which version are you on).
> >
> > I suspect 2.16, as that is a version of Git, in which there happens to be
> > a call into the refs subsystem in submodule--helper.c in line 624.
> >
> > Is it possible to upgrade Git (to v2.18.0 or later) or cherry-pick
> > 74b6bda32f (submodule: check for NULL return of get_submodule_ref_store(),
> > 2018-03-28) into your copy of Git?
> >
> > Thanks,
> > Stefan

```
