Merge lp:~mbp/bzr/109115-memoryerror-message into lp:bzr/2.0

Proposed by Martin Pool
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mbp/bzr/109115-memoryerror-message
Merge into: lp:bzr/2.0
Diff against target: None lines
To merge this branch: bzr merge lp:~mbp/bzr/109115-memoryerror-message
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+11107@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

This adds MemoryError as a special class of error, so Bazaar just says "bzr: out of memory" and logs a traceback to .bzr.log.

There are some cases where we use more memory than we should and obviously we want to fix them. But until they're fixed, and even after everything possible has been done, it'll still be possible to exhaust the machine's memory.

At the moment we get a lot of slightly-confused-looking bug reports about MemoryError. The goal of this change is that:

 * users may realize "oh, I don't really want to commit that 800MB ISO" and be more able to understand and work around whatever hardware or software limits we do have
 * if the limit is unreasonable, they will report a clearer bug about it, or find an existing dupe

This does mean we'll need to ask for a traceback from .bzr.log. I think that's ok.

Maybe we should eventually give an apport traceback but with a customized message.

This is not a high priority but I think it's safe for 2.0.

It's actually a bit hard to make this fail realistically. I got it to happen with

ulimit -v 80000

(ie vm size 80MB) and then diffing a large file. Getting Python etc going takes severals 10s of MB of vm.

Revision history for this message
Vincent Ladeuil (vila) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-09-02 13:32:52 +0000
+++ NEWS 2009-09-03 02:59:56 +0000
@@ -6,8 +6,8 @@
6.. contents:: List of Releases6.. contents:: List of Releases
7 :depth: 17 :depth: 1
88
9bzr 2.0rc29bzr 2.0rc2 (not released yet)
10##########10#############################
1111
12Bug Fixes12Bug Fixes
13*********13*********
@@ -20,6 +20,10 @@
20 revisions that are in the fallback repository. (Regressed in 2.0rc1).20 revisions that are in the fallback repository. (Regressed in 2.0rc1).
21 (John Arbash Meinel, #419241)21 (John Arbash Meinel, #419241)
2222
23* Clearer message when Bazaar runs out of memory, instead of a ``MemoryError``
24 traceback.
25 (Martin Pool, #109115)
26
23* Fix a segmentation fault when computing the ``merge_sort`` of a graph27* Fix a segmentation fault when computing the ``merge_sort`` of a graph
24 that has a ghost in the mainline ancestry.28 that has a ghost in the mainline ancestry.
25 (John Arbash Meinel, #419241)29 (John Arbash Meinel, #419241)
2630
=== modified file 'bzrlib/tests/test_trace.py'
--- bzrlib/tests/test_trace.py 2009-08-20 04:30:16 +0000
+++ bzrlib/tests/test_trace.py 2009-09-03 02:59:56 +0000
@@ -72,6 +72,15 @@
72 self.assertTrue(len(msg) > 0)72 self.assertTrue(len(msg) > 0)
73 self.assertEqualDiff(msg, 'bzr: interrupted\n')73 self.assertEqualDiff(msg, 'bzr: interrupted\n')
7474
75 def test_format_memory_error(self):
76 try:
77 raise MemoryError()
78 except MemoryError:
79 pass
80 msg = _format_exception()
81 self.assertEquals(msg,
82 "bzr: out of memory\n")
83
75 def test_format_os_error(self):84 def test_format_os_error(self):
76 try:85 try:
77 os.rmdir('nosuchfile22222')86 os.rmdir('nosuchfile22222')
7887
=== modified file 'bzrlib/trace.py'
--- bzrlib/trace.py 2009-08-20 05:02:45 +0000
+++ bzrlib/trace.py 2009-09-03 02:59:56 +0000
@@ -432,6 +432,9 @@
432 elif isinstance(exc_object, KeyboardInterrupt):432 elif isinstance(exc_object, KeyboardInterrupt):
433 err_file.write("bzr: interrupted\n")433 err_file.write("bzr: interrupted\n")
434 return errors.EXIT_ERROR434 return errors.EXIT_ERROR
435 elif isinstance(exc_object, MemoryError):
436 err_file.write("bzr: out of memory\n")
437 return errors.EXIT_ERROR
435 elif isinstance(exc_object, ImportError) \438 elif isinstance(exc_object, ImportError) \
436 and str(exc_object).startswith("No module named "):439 and str(exc_object).startswith("No module named "):
437 report_user_error(exc_info, err_file,440 report_user_error(exc_info, err_file,

Subscribers

People subscribed via source and target branches