{"thread":{"id":"11333","subject":"FLEX_ARRAY=1 causes SIGSEGV on SPARC","startedAt":"2007-12-18T01:01:26Z","lastAt":"2007-12-18T01:32:14Z","messageCount":3,"participants":["Shawn O. Pearce","Junio C Hamano","David Kastrup"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"63540","messageId":"20071218010126.GP14735@spearce.org","threadId":"11333","inReplyTo":null,"subject":"FLEX_ARRAY=1 causes SIGSEGV on SPARC","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-12-18T01:01:26Z","receivedAt":"2007-12-18T01:01:26Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"So today I discovered latest master will cause a SIGSEGV on\nSolaris/SPARC if FLEX_ARRAY is defined to the default value of 1.\n\nThe issue is the (old) compiler I'm using from Sun doesn't pass\nthe tests defined in 8e9739914972419baad820e76b44d9720ed885c2 (aka\n\"git-compat-util.h: auto-adjust to compiler support of FLEX_ARRAY\na bit better\") so we fallback to #define FLEX_ARRAY 1.\n\nThen git-pack-objects finds something unaligned and segfaults.\nIt always segfaults.  During the deltification phase.  Probably it\nwas working on deltifying loose objects; the set I fed it was about\n100 most recent objects so they were probably all loose.\n\nI'll try to track it down tomorrow.  But the immediate workaround was\nto just add '-DFLEX_ARRAY=/* empty */' to my CFLAGS and recompile\nthe world.  This compiler accepts the empty FLEX_ARRAY macro but\nI'm not sure what feature test(s) would be necessary to make Git\nable to automatically set that, seeing as how the tests defined in\n8e97 are perfectly reasonable and didn't pass.\n\nYea, yea, shame on me for not testing Git since Nov 20th on this\nsystem... I should have caught the failure sooner.  I'm buried in\nnon-Git work these days, but will try to come up with a reasonable\ndetection patch.  Maybe someone will beat me to it.  :-)\n\n-- \nShawn.\n"},{"id":"63541","messageId":"7vtzmg3j37.fsf@gitster.siamese.dyndns.org","threadId":"11333","inReplyTo":"20071218010126.GP14735@spearce.org","subject":"Re: FLEX_ARRAY=1 causes SIGSEGV on SPARC","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-18T01:08:44Z","receivedAt":"2007-12-18T01:08:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> I'll try to track it down tomorrow.  But the immediate workaround was\n> to just add '-DFLEX_ARRAY=/* empty */' to my CFLAGS and recompile\n> the world.  This compiler accepts the empty FLEX_ARRAY macro but\n> I'm not sure what feature test(s) would be necessary to make Git\n> able to automatically set that, seeing as how the tests defined in\n> 8e97 are perfectly reasonable and didn't pass.\n> ..., but will try to come up with a reasonable\n> detection patch....\n\nActually I would be more worried about the breakage in FLEX_ARRAY=1 case\nthan misdetection.  Even if your compiler supports the flexible array\nmembers, the fallback to FLEX_ARRAY=1 ought to work and you are seeing a\ncase where it doesn't.\n"},{"id":"63547","messageId":"85wsrclqmi.fsf_-_@lola.goethe.zz","threadId":"11333","inReplyTo":"7vtzmg3j37.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] diff-delta.c: make FLEX_ARRAY=1 work.","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-12-18T01:32:14Z","receivedAt":"2007-12-18T01:32:14Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"\nI remarked previously that diff-delta.c does not work with FLEX_ARRAY=1.\nHere is one attempt to change this.  It conceivably still suffers from\npotential misalignment problems (which would likely need some union type\nmagic to avoid 100%), but at least the index calculation should not go\nas horribly wrong as previously.\n\n---\nJunio C Hamano <gitster@pobox.com> writes:\n\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n>\n>> I'll try to track it down tomorrow.  But the immediate workaround was\n>> to just add '-DFLEX_ARRAY=/* empty */' to my CFLAGS and recompile\n>> the world.  This compiler accepts the empty FLEX_ARRAY macro but\n>> I'm not sure what feature test(s) would be necessary to make Git\n>> able to automatically set that, seeing as how the tests defined in\n>> 8e97 are perfectly reasonable and didn't pass.\n>> ..., but will try to come up with a reasonable\n>> detection patch....\n>\n> Actually I would be more worried about the breakage in FLEX_ARRAY=1 case\n> than misdetection.  Even if your compiler supports the flexible array\n> members, the fallback to FLEX_ARRAY=1 ought to work and you are seeing a\n> case where it doesn't.\n\n diff-delta.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 9e440a9..099235c 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -247,7 +247,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \t/* Now create the packed index in array form rather than\n \t * linked lists */\n \n-\tmemsize = sizeof(*index)\n+\tmemsize = (char *)&index->hash - (char *)index\n \t\t+ sizeof(*packed_hash) * (hsize+1)\n \t\t+ sizeof(*packed_entry) * entries;\n \n@@ -264,7 +264,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \tindex->src_size = bufsize;\n \tindex->hash_mask = hmask;\n \n-\tmem = index + 1;\n+\tmem = &index->hash;\n \tpacked_hash = mem;\n \tmem = packed_hash + (hsize+1);\n \tpacked_entry = mem;\n-- \n1.5.3.6.995.ge8abd\n"}]}