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
1=== modified file 'NEWS'
2--- NEWS 2009-09-02 13:32:52 +0000
3+++ NEWS 2009-09-03 02:59:56 +0000
4@@ -6,8 +6,8 @@
5 .. contents:: List of Releases
6 :depth: 1
7
8-bzr 2.0rc2
9-##########
10+bzr 2.0rc2 (not released yet)
11+#############################
12
13 Bug Fixes
14 *********
15@@ -20,6 +20,10 @@
16 revisions that are in the fallback repository. (Regressed in 2.0rc1).
17 (John Arbash Meinel, #419241)
18
19+* Clearer message when Bazaar runs out of memory, instead of a ``MemoryError``
20+ traceback.
21+ (Martin Pool, #109115)
22+
23 * Fix a segmentation fault when computing the ``merge_sort`` of a graph
24 that has a ghost in the mainline ancestry.
25 (John Arbash Meinel, #419241)
26
27=== modified file 'bzrlib/tests/test_trace.py'
28--- bzrlib/tests/test_trace.py 2009-08-20 04:30:16 +0000
29+++ bzrlib/tests/test_trace.py 2009-09-03 02:59:56 +0000
30@@ -72,6 +72,15 @@
31 self.assertTrue(len(msg) > 0)
32 self.assertEqualDiff(msg, 'bzr: interrupted\n')
33
34+ def test_format_memory_error(self):
35+ try:
36+ raise MemoryError()
37+ except MemoryError:
38+ pass
39+ msg = _format_exception()
40+ self.assertEquals(msg,
41+ "bzr: out of memory\n")
42+
43 def test_format_os_error(self):
44 try:
45 os.rmdir('nosuchfile22222')
46
47=== modified file 'bzrlib/trace.py'
48--- bzrlib/trace.py 2009-08-20 05:02:45 +0000
49+++ bzrlib/trace.py 2009-09-03 02:59:56 +0000
50@@ -432,6 +432,9 @@
51 elif isinstance(exc_object, KeyboardInterrupt):
52 err_file.write("bzr: interrupted\n")
53 return errors.EXIT_ERROR
54+ elif isinstance(exc_object, MemoryError):
55+ err_file.write("bzr: out of memory\n")
56+ return errors.EXIT_ERROR
57 elif isinstance(exc_object, ImportError) \
58 and str(exc_object).startswith("No module named "):
59 report_user_error(exc_info, err_file,

Subscribers

People subscribed via source and target branches