From 43a9e24a52fa867db98fc2195b8db85b4729e7a1 Mon Sep 17 00:00:00 2001 From: "tommi@chromium.org" Date: Wed, 6 Apr 2011 17:42:45 +0000 Subject: Switch out use of std::string and std::vector for large allocations for a buffer class that doesn't throw exceptions. The new buffer class is pretty simple and relies on the MemoryAllocator class that I previously to back large allocations with mapped files when memory is scarce. That reduced the number of crashes quite a bit but we still crash on machines that are simply out of diskspace as well. So, the right thing to do is to expect and handle failures which is what this cl is all about. What we should see once this has landed is that crash dumps due to courgette running out of disk space should disappear from crash/ and instead we should see the number of users that run into this particular problem in dashboards. TEST=Courgette out-of-memory/out-of-diskspace errors should disappear from crash/ BUG=74777 Review URL: http://codereview.chromium.org/6677141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80648 0039d316-1c4b-4281-b951-d872f2087c98 --- courgette/courgette_tool.cc | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'courgette/courgette_tool.cc') diff --git a/courgette/courgette_tool.cc b/courgette/courgette_tool.cc index 523a438..225906e 100644 --- a/courgette/courgette_tool.cc +++ b/courgette/courgette_tool.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -303,20 +303,39 @@ void ApplyEnsemblePatch(const std::wstring& old_file, #endif courgette::Status status = - courgette::ApplyEnsemblePatch(old_path.value().c_str(), - patch_path.value().c_str(), - new_path.value().c_str()); + courgette::ApplyEnsemblePatch(old_path.value().c_str(), + patch_path.value().c_str(), + new_path.value().c_str()); if (status == courgette::C_OK) return; // Diagnose the error. - if (status == courgette::C_BAD_ENSEMBLE_MAGIC) - Problem("Not a courgette patch"); - if (status == courgette::C_BAD_ENSEMBLE_VERSION) - Problem("Wrong version patch"); - if (status == courgette::C_BAD_ENSEMBLE_HEADER) - Problem("Corrupt patch"); + switch (status) { + case courgette::C_BAD_ENSEMBLE_MAGIC: + Problem("Not a courgette patch"); + break; + + case courgette::C_BAD_ENSEMBLE_VERSION: + Problem("Wrong version patch"); + break; + + case courgette::C_BAD_ENSEMBLE_HEADER: + Problem("Corrupt patch"); + break; + + case courgette::C_DISASSEMBLY_FAILED: + Problem("Disassembly failed (could be because of memory issues)"); + break; + + case courgette::C_STREAM_ERROR: + Problem("Stream error (likely out of memory or disk space)"); + break; + + default: + break; + } + // If we failed due to a missing input file, this will // print the message. std::string old_buffer = ReadOrFail(old_file, "'old' input"); -- cgit v1.1