git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* SEGV when lookup_* returns NULL
@ 2006-11-27 21:13 Martin Waitz
  2006-11-27 21:55 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Waitz @ 2006-11-27 21:13 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SEGV when lookup_* returns NULL
  2006-11-27 21:13 SEGV when lookup_* returns NULL Martin Waitz
@ 2006-11-27 21:55 ` Junio C Hamano
  2006-11-27 23:33   ` Johannes Schindelin
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-11-27 21:55 UTC (permalink / raw)
  To: Martin Waitz; +Cc: git

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SEGV when lookup_* returns NULL
  2006-11-27 21:55 ` Junio C Hamano
@ 2006-11-27 23:33   ` Johannes Schindelin
  2006-11-28  0:13     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2006-11-27 23:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Martin Waitz, git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SEGV when lookup_* returns NULL
  2006-11-27 23:33   ` Johannes Schindelin
@ 2006-11-28  0:13     ` Junio C Hamano
  2006-11-28  2:23       ` Morten Welinder
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-11-28  0:13 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Martin Waitz, git

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?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SEGV when lookup_* returns NULL
  2006-11-28  0:13     ` Junio C Hamano
@ 2006-11-28  2:23       ` Morten Welinder
  0 siblings, 0 replies; 5+ messages in thread
From: Morten Welinder @ 2006-11-28  2:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, Martin Waitz, git

> 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-11-28  2:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-27 21:13 SEGV when lookup_* returns NULL Martin Waitz
2006-11-27 21:55 ` Junio C Hamano
2006-11-27 23:33   ` Johannes Schindelin
2006-11-28  0:13     ` Junio C Hamano
2006-11-28  2:23       ` Morten Welinder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).