# Segmentation fault with latest git (070c57df)

4 messages from 2013-01-31 to 2013-01-31. Participants: Jongman Heo, Jeff King, Antoine Pelisse.
Thread: https://gitlist.dev/t/32786

## Jongman Heo, 2013-01-31 01:35

Subject: Segmentation fault with latest git (070c57df)
Message-ID: <28799936.346521359596121253.JavaMail.weblogic@epmltmp3>
URL: https://gitlist.dev/e/28799936.346521359596121253.JavaMail.weblogic%40epmltmp3

```

Hi all,

Looks like following commit causes a segmentation fault in my machine (when running git pull or git fetch);

commit 8dd5afc926acb9829ebf56e9b78826a5242cd638
Author: Junio C Hamano <gitster@pobox.com>
Date:   Mon Jan 7 12:24:55 2013 -0800

    string-list: allow case-insensitive string list


In my case, list->cmp (at get_entry_index() function) has an invalid address, obviously not an address of string comparision function, instead it points to 1.


Regards,
Jongman Heo.
```

## Jeff King, 2013-01-31 06:49

Subject: Re: Segmentation fault with latest git (070c57df)
Message-ID: <20130131064921.GB24660@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130131064921.GB24660%40sigill.intra.peff.net
In-Reply-To: <28799936.346521359596121253.JavaMail.weblogic@epmltmp3>

```
On Thu, Jan 31, 2013 at 01:35:21AM +0000, Jongman Heo wrote:

> Looks like following commit causes a segmentation fault in my machine
> (when running git pull or git fetch);
> 
> commit 8dd5afc926acb9829ebf56e9b78826a5242cd638
> Author: Junio C Hamano <gitster@pobox.com>
> Date:   Mon Jan 7 12:24:55 2013 -0800
> 
>     string-list: allow case-insensitive string list
> 
> 
> In my case, list->cmp (at get_entry_index() function) has an invalid
> address, obviously not an address of string comparision function,
> instead it points to 1.

Can you show us a stack trace? The string-list functions are generic and
get called in a lot of places. It would be useful to know which list is
causing the problem.

-Peff

```

## Antoine Pelisse, 2013-01-31 07:02

Subject: Re: Segmentation fault with latest git (070c57df)
Message-ID: <CALWbr2y8veWYRwEGrbGq-PhxZjXbBF5HMgQXrRr=1JzGQ9Y-tQ@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2y8veWYRwEGrbGq-PhxZjXbBF5HMgQXrRr%3D1JzGQ9Y-tQ%40mail.gmail.com
In-Reply-To: <20130131064921.GB24660@sigill.intra.peff.net>

```
In "clean.c" we have a "string_list" created on the stack with
"STRING_LIST_INIT_NODUP" (there are probably others, I stopped at the
first occurrence).
But, "STRING_LIST_INIT_NODUP" doesn't init the "list->cmp" pointer
which can thus be random.

I don't have much time to provide a patch right now (have to go to
work), but will tonight if still needed.

Antoine,



On Thu, Jan 31, 2013 at 7:49 AM, Jeff King <peff@peff.net> wrote:
> On Thu, Jan 31, 2013 at 01:35:21AM +0000, Jongman Heo wrote:
>
>> Looks like following commit causes a segmentation fault in my machine
>> (when running git pull or git fetch);
>>
>> commit 8dd5afc926acb9829ebf56e9b78826a5242cd638
>> Author: Junio C Hamano <gitster@pobox.com>
>> Date:   Mon Jan 7 12:24:55 2013 -0800
>>
>>     string-list: allow case-insensitive string list
>>
>>
>> In my case, list->cmp (at get_entry_index() function) has an invalid
>> address, obviously not an address of string comparision function,
>> instead it points to 1.
>
> Can you show us a stack trace? The string-list functions are generic and
> get called in a lot of places. It would be useful to know which list is
> causing the problem.
>
> -Peff
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```

## Jeff King, 2013-01-31 07:35

Subject: Re: Segmentation fault with latest git (070c57df)
Message-ID: <20130131073543.GA5342@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130131073543.GA5342%40sigill.intra.peff.net
In-Reply-To: <CALWbr2y8veWYRwEGrbGq-PhxZjXbBF5HMgQXrRr=1JzGQ9Y-tQ@mail.gmail.com>

```
On Thu, Jan 31, 2013 at 08:02:06AM +0100, Antoine Pelisse wrote:

> In "clean.c" we have a "string_list" created on the stack with
> "STRING_LIST_INIT_NODUP" (there are probably others, I stopped at the
> first occurrence).
> But, "STRING_LIST_INIT_NODUP" doesn't init the "list->cmp" pointer
> which can thus be random.

I don't think that is the problem. Extra struct members that are not
mentioned by an initializer will get set to 0 or NULL.

A code path that tried to initialize each member individually would run
into problems, but I could not find any such code path (all of them
either use an initializer, are static, or memset the struct to
all-zeroes).

-Peff

```
