Skip to contentSkip to conversation

SEGV when lookup_* returns NULL

DISCUSSION Martin Waitz 4 participants 5 messages Aug 11, 2016

lore
Share & tools
lore
#4 lore raw
Quoted 2 lines

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.

#2 lore raw
In reply to Junio C Hamano

Hi,

Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Martin Waitz

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.

Quoted 6 lines
Quoted 1 line

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

#1 lore raw
In reply to Martin Waitz
Quoted 5 lines · Martin Waitz

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.

#0 lore raw

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.

Signature · 1 line
Martin Waitz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFa1Tqj/Eaxd/oD7IRAjNtAJ940+c/Z5AvGk/gx2lTCXd5oFYNmgCfccvQ ph2T49HvIMnLfao8Hx7HfAk=
=OUCc
-----END PGP SIGNATURE-----