{"thread":{"id":"43555","subject":"Re: SEGV when lookup_* returns NULL","startedAt":"2006-11-27T21:13:15Z","lastAt":"2006-11-28T02:23:47Z","messageCount":5,"participants":["Junio C Hamano","Morten Welinder","Johannes Schindelin","Martin Waitz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"298422","messageId":"20061127211315.GC18810@admingilde.org","threadId":"43555","inReplyTo":null,"subject":"SEGV when lookup_* returns NULL","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-11-27T21:13:15Z","receivedAt":"2006-11-27T21:13:15Z","isPatch":false,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nWhen trying to an unmodified GIT on a repository with submodules\nit segfaults a lot.\n\nAll the lookup_{blob,tree,commit} functions check that the object\nreally is of the requested type and return NULL otherwise.\nHowever this NULL pointer is not checked in the calling functions.\n\nShould we make lookup_* to just die when invoked on another object-type?\nOr modify all the callers?\nIs there a sane error-handling strategy besides dying in this case?\nReally checking all the return values in the whole chain would be\na lot of work.\n\n-- \nMartin Waitz\n"},{"id":"298314","messageId":"7vu00kftbq.fsf@assigned-by-dhcp.cox.net","threadId":"43555","inReplyTo":"20061127211315.GC18810@admingilde.org","subject":"Re: SEGV when lookup_* returns NULL","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-27T21:55:21Z","receivedAt":"2006-11-27T21:55:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Waitz <tali@admingilde.org> writes:\n\n> All the lookup_{blob,tree,commit} functions check that the object\n> really is of the requested type and return NULL otherwise.\n> However this NULL pointer is not checked in the calling functions.\n>\n> Should we make lookup_* to just die when invoked on another object-type?\n\nMaking lookup_{specific type} die when they see unexpected type\nwould not hurt that much, I think, aside from the possibility\nthat some callers may check NULL to see if object already\nexists, but they should be using has_sha1_file() instead.\n"},{"id":"297216","messageId":"Pine.LNX.4.63.0611280032300.30004@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43555","inReplyTo":"7vu00kftbq.fsf@assigned-by-dhcp.cox.net","subject":"Re: SEGV when lookup_* returns NULL","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-11-27T23:33:24Z","receivedAt":"2006-11-27T23:33:24Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 27 Nov 2006, Junio C Hamano wrote:\n\n> Martin Waitz <tali@admingilde.org> writes:\n> \n> > All the lookup_{blob,tree,commit} functions check that the object\n> > really is of the requested type and return NULL otherwise.\n> > However this NULL pointer is not checked in the calling functions.\n> >\n> > Should we make lookup_* to just die when invoked on another object-type?\n> \n> Making lookup_{specific type} die when they see unexpected type\n> would not hurt that much, I think, aside from the possibility\n> that some callers may check NULL to see if object already\n> exists, but they should be using has_sha1_file() instead.\n\nAnd it would totally clobber the long term goal of libifying git.\n\nCiao,\nDscho\n"},{"id":"295462","messageId":"7v3b84e8cg.fsf@assigned-by-dhcp.cox.net","threadId":"43555","inReplyTo":"Pine.LNX.4.63.0611280032300.30004@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: SEGV when lookup_* returns NULL","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-28T00:13:51Z","receivedAt":"2006-11-28T00:13:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> And it would totally clobber the long term goal of libifying git.\n\nWhy?  You would certainly install your own die() handler by that\ntime I presume?\n"},{"id":"296273","messageId":"118833cc0611271823t3b1783cem38f031ac26ac0f94@mail.gmail.com","threadId":"43555","inReplyTo":"7v3b84e8cg.fsf@assigned-by-dhcp.cox.net","subject":"Re: SEGV when lookup_* returns NULL","fromName":"Morten Welinder","fromEmail":"mwelinder@gmail.com","sentAt":"2006-11-28T02:23:47Z","receivedAt":"2006-11-28T02:23:47Z","isPatch":false,"sender":{"key":"mwelinder@gmail.com","avatar":null},"body":"> Why?  You would certainly install your own die() handler by that\n> time I presume?\n\nLikely, but short of exiting or using longjmp/setjmp what can you do\nin such a \"die\"?  Not much.  And most GUI users will be unhappy\nwith the exit approach.\n\nIf there is any chance that the error is not the programmer's fault, a\nnice library ought to pass the error back somehow.\n\n"}]}