From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Duy Nguyen <pclouds@gmail.com>,
Jonathan Tan <jonathantanmy@google.com>
Subject: [PATCH v2] fetch-pack: clear alternate shallow when complete
Date: Wed, 6 Feb 2019 23:59:37 +0000 [thread overview]
Message-ID: <20190206235937.201663-1-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20190204000650.686175-1-sandals@crustytoothpaste.net>
When we write an alternate shallow file in update_shallow, we write it
into the lock file. The string stored in alternate_shallow_file is
copied from the lock file path, but it is freed the moment that the lock
file is closed, since we call strbuf_release to free that path.
This used to work, since we did not invoke git index-pack more than
once. However, we now do, and starting with bd0b42aed3 (fetch-pack: do
not take shallow lock unnecessarily - 2019-01-10), we no longer reset
this value unconditionally; consequently, we reuse the freed memory.
Ensure we reset the value to NULL to avoid using freed memory. git
index-pack will read the repository's shallow file, which will have been
updated with the correct information.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
fetch-pack.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fetch-pack.c b/fetch-pack.c
index 577faa6229..a92621a388 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1272,6 +1272,8 @@ static void receive_shallow_info(struct fetch_pack_args *args,
setup_alternate_shallow(&shallow_lock, &alternate_shallow_file,
NULL);
args->deepen = 1;
+ } else {
+ alternate_shallow_file = NULL;
}
}
@@ -1489,6 +1491,7 @@ static void update_shallow(struct fetch_pack_args *args,
rollback_lock_file(&shallow_lock);
} else
commit_lock_file(&shallow_lock);
+ alternate_shallow_file = NULL;
return;
}
@@ -1512,6 +1515,7 @@ static void update_shallow(struct fetch_pack_args *args,
&alternate_shallow_file,
&extra);
commit_lock_file(&shallow_lock);
+ alternate_shallow_file = NULL;
}
oid_array_clear(&extra);
return;
@@ -1551,6 +1555,7 @@ static void update_shallow(struct fetch_pack_args *args,
commit_lock_file(&shallow_lock);
oid_array_clear(&extra);
oid_array_clear(&ref);
+ alternate_shallow_file = NULL;
return;
}
next prev parent reply other threads:[~2019-02-06 23:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 8:58 t5702 failing under ASan on master brian m. carlson
2019-01-30 10:07 ` Duy Nguyen
2019-01-30 11:40 ` brian m. carlson
2019-01-31 18:12 ` Junio C Hamano
2019-02-04 0:06 ` [PATCH] fetch-pack: clear alternate shallow when complete brian m. carlson
2019-02-04 10:34 ` Duy Nguyen
2019-02-05 16:26 ` Jonathan Tan
2019-02-06 23:26 ` brian m. carlson
2019-02-06 23:59 ` brian m. carlson [this message]
2019-02-07 2:32 ` [PATCH v2] " Duy Nguyen
2019-02-07 2:47 ` Junio C Hamano
2019-02-07 2:53 ` Junio C Hamano
2019-02-07 4:07 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190206235937.201663-1-sandals@crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).