Merge lp:~weyrick/bzr/720853-max-recursion-depth into lp:bzr

Proposed by Shannon Weyrick
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 6268
Proposed branch: lp:~weyrick/bzr/720853-max-recursion-depth
Merge into: lp:bzr
Diff against target: 58 lines (+18/-0)
3 files modified
bzrlib/btree_index.py (+7/-0)
bzrlib/tests/test_btree_index.py (+8/-0)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~weyrick/bzr/720853-max-recursion-depth
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+82453@code.launchpad.net

Commit message

Raise BadIndexKey rather than crashing if the key is unreasonably long.

Description of the change

Version 2 of this patch, which fixes the recursion issue in a way that doesn't break the pack command

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/16/2011 10:09 PM, Shannon Weyrick wrote:
> Shannon Weyrick has proposed merging
> lp:~weyrick/bzr/720853-max-recursion-depth into lp:bzr.
>
> Requested reviews: bzr-core (bzr-core) Related bugs: Bug #720853 in
> Bazaar: "bzr crashed with RuntimeError in normpath(): maximum
> recursion depth exceeded while calling a Python object"
> https://bugs.launchpad.net/bzr/+bug/720853 Bug #889872 in Bazaar:
> "not a valid key error" https://bugs.launchpad.net/bzr/+bug/889872
>
> For more details, see:
> https://code.launchpad.net/~weyrick/bzr/720853-max-recursion-depth/+merge/82453
>
> Version 2 of this patch, which fixes the recursion issue in a way
> that doesn't break the pack command

 merge: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7E3pAACgkQJdeBCYSNAANS6wCg11uEStRmQaGk38pF45DgkuOh
Ef4AoJh16ykm7zk+kIa7PPwiRSlY4yZu
=l+zk
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/btree_index.py'
--- bzrlib/btree_index.py 2011-11-14 04:46:48 +0000
+++ bzrlib/btree_index.py 2011-11-16 21:07:26 +0000
@@ -294,8 +294,10 @@
294 flag when writing out. This is used by the _spill_mem_keys_to_disk294 flag when writing out. This is used by the _spill_mem_keys_to_disk
295 functionality.295 functionality.
296 """296 """
297 new_leaf = False
297 if rows[-1].writer is None:298 if rows[-1].writer is None:
298 # opening a new leaf chunk;299 # opening a new leaf chunk;
300 new_leaf = True
299 for pos, internal_row in enumerate(rows[:-1]):301 for pos, internal_row in enumerate(rows[:-1]):
300 # flesh out any internal nodes that are needed to302 # flesh out any internal nodes that are needed to
301 # preserve the height of the tree303 # preserve the height of the tree
@@ -320,6 +322,11 @@
320 optimize_for_size=self._optimize_for_size)322 optimize_for_size=self._optimize_for_size)
321 rows[-1].writer.write(_LEAF_FLAG)323 rows[-1].writer.write(_LEAF_FLAG)
322 if rows[-1].writer.write(line):324 if rows[-1].writer.write(line):
325 # if we failed to write, despite having an empty page to write to,
326 # then line is too big. raising the error avoids infinite recursion
327 # searching for a suitably large page that will not be found.
328 if new_leaf:
329 raise errors.BadIndexKey(string_key)
323 # this key did not fit in the node:330 # this key did not fit in the node:
324 rows[-1].finish_node()331 rows[-1].finish_node()
325 key_line = string_key + "\n"332 key_line = string_key + "\n"
326333
=== modified file 'bzrlib/tests/test_btree_index.py'
--- bzrlib/tests/test_btree_index.py 2011-11-14 04:46:48 +0000
+++ bzrlib/tests/test_btree_index.py 2011-11-16 21:07:26 +0000
@@ -831,6 +831,14 @@
831 btree_index.BTreeGraphIndex(t1, 'index', 10) !=831 btree_index.BTreeGraphIndex(t1, 'index', 10) !=
832 btree_index.BTreeGraphIndex(t1, 'index', 20))832 btree_index.BTreeGraphIndex(t1, 'index', 20))
833833
834 def test_key_too_big(self):
835 # the size that matters here is the _compressed_ size of the key, so we can't
836 # do a simple character repeat.
837 bigKey = ''.join(map(repr, xrange(btree_index._PAGE_SIZE)))
838 self.assertRaises(errors.BadIndexKey,
839 self.make_index,
840 nodes=[((bigKey,), 'value', ())])
841
834 def test_iter_all_only_root_no_size(self):842 def test_iter_all_only_root_no_size(self):
835 self.make_index(nodes=[(('key',), 'value', ())])843 self.make_index(nodes=[(('key',), 'value', ())])
836 t = transport.get_transport_from_url('trace+' + self.get_url(''))844 t = transport.get_transport_from_url('trace+' + self.get_url(''))
837845
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- doc/en/release-notes/bzr-2.5.txt 2011-11-16 17:04:48 +0000
+++ doc/en/release-notes/bzr-2.5.txt 2011-11-16 21:07:26 +0000
@@ -529,6 +529,9 @@
529 operations that use it, like merge, can now create trees without a root.529 operations that use it, like merge, can now create trees without a root.
530 (Aaron Bentley)530 (Aaron Bentley)
531531
532* Raise BadIndexKey exception in btree_index when a key is too large, fixing
533 an infinite recursion issue. (Shannon Weyrick, #720853)
534
532Documentation535Documentation
533*************536*************
534537