Mercurial > hg
view tests/test-push-hook-lock.t @ 24710:909ee6b2a024
lazymanifest: prevent leak when updating an entry more than once
__setitem__ on the lazymanifest C type wasn't checking to see if a
line had previously been malloced before replacing it, leading to
leaks if files got updated multiple times in the course of a task.
I was able to reproduce the leak with this change to test-manifest.py:
diff --git a/tests/test-manifest.py b/tests/test-manifest.py
--- a/tests/test-manifest.py
+++ b/tests/test-manifest.py
@@ -456,6 +456,16 @@ class basemanifesttests(object):
['a/b/c/bar.txt', 'a/b/c/foo.txt', 'a/b/d/ten.txt'],
m2.keys())
+ def testManifestSetItem(self):
+ m = self.parsemanifest('')
+ for x in range(3):
+ m['file%d' % x] = BIN_HASH_1
+ for x in range(3):
+ m['file%d' % x] = BIN_HASH_2
+ import time
+ time.sleep(4)
+
+
along with the commands:
$ make local
$ PYTHONPATH=. SILENT_BE_NOISY=1 python tests/test-manifest.py testmanifestdict.testManifestSetItem &
$ sleep 4
$ leaks $(jobs -p | tee /dev/stderr | awk '{print $3}')
$ wait
in an interactive shell on OS X. As far as I can tell, it had to be an
interactive shell so that I could get the pid of the test run using
the jobs builtin. Prior to this change, I was leaking several strings,
and after this change leaks reports no leaks.
I thought there was a bug filed for this in bugzilla, but I can't find
it either in bugzilla or by searching my email.
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 11 Apr 2015 11:56:21 -0400 |
parents | 7dd1870120b2 |
children | 00e4c5601c74 |
line wrap: on
line source
$ hg init 1 $ echo '[ui]' >> 1/.hg/hgrc $ echo 'timeout = 10' >> 1/.hg/hgrc $ echo foo > 1/foo $ hg --cwd 1 ci -A -m foo adding foo $ hg clone 1 2 updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg clone 2 3 updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cat <<EOF > $TESTTMP/debuglocks-pretxn-hook.sh > hg debuglocks > true > EOF $ echo '[hooks]' >> 2/.hg/hgrc $ echo "pretxnchangegroup.a = sh $TESTTMP/debuglocks-pretxn-hook.sh" >> 2/.hg/hgrc $ echo 'changegroup.push = hg push -qf ../1' >> 2/.hg/hgrc $ echo bar >> 3/foo $ hg --cwd 3 ci -m bar $ hg --cwd 3 push ../2 pushing to ../2 searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files lock: user *, process * (*s) (glob) wlock: free