# Re: SEGV when lookup_* returns NULL

5 messages from 2006-11-27 to 2006-11-28. Participants: Junio C Hamano, Morten Welinder, Johannes Schindelin, Martin Waitz.
Thread: https://gitlist.dev/t/43555

## Martin Waitz, 2006-11-27 21:13

Subject: SEGV when lookup_* returns NULL
Message-ID: <20061127211315.GC18810@admingilde.org>
URL: https://gitlist.dev/e/20061127211315.GC18810%40admingilde.org

```
hoi :)

When trying to an unmodified GIT on a repository with submodules
it segfaults a lot.

All the lookup_{blob,tree,commit} functions check that the object
really is of the requested type and return NULL otherwise.
However this NULL pointer is not checked in the calling functions.

Should we make lookup_* to just die when invoked on another object-type?
Or modify all the callers?
Is there a sane error-handling strategy besides dying in this case?
Really checking all the return values in the whole chain would be
a lot of work.

-- 
Martin Waitz

```

## Junio C Hamano, 2006-11-27 21:55

Subject: Re: SEGV when lookup_* returns NULL
Message-ID: <7vu00kftbq.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vu00kftbq.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20061127211315.GC18810@admingilde.org>

```
Martin Waitz <tali@admingilde.org> writes:

> All the lookup_{blob,tree,commit} functions check that the object
> really is of the requested type and return NULL otherwise.
> However this NULL pointer is not checked in the calling functions.
>
> Should we make lookup_* to just die when invoked on another object-type?

Making lookup_{specific type} die when they see unexpected type
would not hurt that much, I think, aside from the possibility
that some callers may check NULL to see if object already
exists, but they should be using has_sha1_file() instead.

```

## Johannes Schindelin, 2006-11-27 23:33

Subject: Re: SEGV when lookup_* returns NULL
Message-ID: <Pine.LNX.4.63.0611280032300.30004@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0611280032300.30004%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vu00kftbq.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Mon, 27 Nov 2006, Junio C Hamano wrote:

> Martin Waitz <tali@admingilde.org> writes:
> 
> > All the lookup_{blob,tree,commit} functions check that the object
> > really is of the requested type and return NULL otherwise.
> > However this NULL pointer is not checked in the calling functions.
> >
> > Should we make lookup_* to just die when invoked on another object-type?
> 
> Making lookup_{specific type} die when they see unexpected type
> would not hurt that much, I think, aside from the possibility
> that some callers may check NULL to see if object already
> exists, but they should be using has_sha1_file() instead.

And it would totally clobber the long term goal of libifying git.

Ciao,
Dscho

```

## Junio C Hamano, 2006-11-28 00:13

Subject: Re: SEGV when lookup_* returns NULL
Message-ID: <7v3b84e8cg.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v3b84e8cg.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0611280032300.30004@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> And it would totally clobber the long term goal of libifying git.

Why?  You would certainly install your own die() handler by that
time I presume?

```

## Morten Welinder, 2006-11-28 02:23

Subject: Re: SEGV when lookup_* returns NULL
Message-ID: <118833cc0611271823t3b1783cem38f031ac26ac0f94@mail.gmail.com>
URL: https://gitlist.dev/e/118833cc0611271823t3b1783cem38f031ac26ac0f94%40mail.gmail.com
In-Reply-To: <7v3b84e8cg.fsf@assigned-by-dhcp.cox.net>

```
> Why?  You would certainly install your own die() handler by that
> time I presume?

Likely, but short of exiting or using longjmp/setjmp what can you do
in such a "die"?  Not much.  And most GUI users will be unhappy
with the exit approach.

If there is any chance that the error is not the programmer's fault, a
nice library ought to pass the error back somehow.


```
