{"thread":{"id":"1498","subject":"[PATCH] fix git-checkout-cache segfault on parisc","startedAt":"2005-08-13T15:29:32Z","lastAt":"2005-08-13T15:29:32Z","messageCount":1,"participants":["James Bottomley"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7191","messageId":"1123946972.5115.4.camel@mulgrave","threadId":"1498","inReplyTo":null,"subject":"[PATCH] fix git-checkout-cache segfault on parisc","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-08-13T15:29:32Z","receivedAt":"2005-08-13T15:29:32Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"This one I think is Linus' fault, so send him a brown paper bag with my\ncomplements ...\n\nThe index cleanup code is executed via atexit() which is *after* main\nhas completed, so the stack allocated cache_file has gone out of scope.\nParisc seems to use stack in the destructor functions, so cache_file\ngets partially overwritten leading to the predictable disastrous\nconsequences.\n\nSigned-off-by: James Bottomley <James.Bottomley@SteelEye.com>\n\n---\n\nJames\n\ndiff --git a/checkout-cache.c b/checkout-cache.c\n--- a/checkout-cache.c\n+++ b/checkout-cache.c\n@@ -80,10 +80,11 @@ static int checkout_all(void)\n static const char checkout_cache_usage[] =\n \"git-checkout-cache [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] [--] <file>...\";\n \n+static struct cache_file cache_file;\n+\n int main(int argc, char **argv)\n {\n \tint i, force_filename = 0;\n-\tstruct cache_file cache_file;\n \tint newfd = -1;\n \n \tif (read_cache() < 0) {\ndiff --git a/index.c b/index.c\n"}]}