Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1381)

Issue 1351373002: Tweaks to SharedMemory to avoid CHECK when printing

Created:
5 years, 3 months ago by brucedawson
Modified:
4 years, 11 months ago
CC:
chromium-reviews, gavinp+memory_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Tweaks to SharedMemory to avoid CHECK when printing The PDF printing code set INVALID_HANDLE_VALUE but SharedMemory could only correctly handle NULL. This change fixes SharedMemory to be more forgiving and fixes the PDF printing code to be consistent. I'm glad that the new SharedMemory error checking found a bug, but I wish it had been something more meaningful. R=rvargas@chromium.org,sdefresne@chromium.org BUG=533310

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -7 lines) Patch
M base/memory/shared_memory_win.cc View 5 chunks +6 lines, -6 lines 3 comments Download
M components/printing/renderer/print_web_view_helper_pdf_win.cc View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 3 (1 generated)
brucedawson
I spot checked five of the crashes caused by my error checking. In all cases ...
5 years, 3 months ago (2015-09-18 19:57:52 UTC) #1
rvargas (doing something else)
5 years, 3 months ago (2015-09-18 22:36:26 UTC) #2
Note: <rants> are not directed at you. You're just the unlucky guy trying to fix
this.

https://codereview.chromium.org/1351373002/diff/1/base/memory/shared_memory_w...
File base/memory/shared_memory_win.cc (right):

https://codereview.chromium.org/1351373002/diff/1/base/memory/shared_memory_w...
base/memory/shared_memory_win.cc:77: return handle != NULL && handle !=
INVALID_HANDLE_VALUE;
<rant>
I know I'm grumpy, but this pattern doesn't make sense with or without this
change :(.

I know this is not what this method is promising, but there's no way to see if a
random handle is valid, and I'd rather remove this method completely and leave
that job to whoever is creating the handle (aka, remove raw handles completely).

Now, I understand that fix would be out of the scope of the current problem.

If we go with the current API, if a caller grabs a number from a hat and uses
it, it's basically depending on the internal implementation of this class, so
widening the range of values that we won't complain about is... kind of silly? I
hear that we should make this less prone to misuse, but really, we should fix
the API instead of adding knee pads to the cutting edges. We should be using
ScopedHandles here, and the caller should be using ScopedHandles, even if we end
up passing the raw handle through the interface.
</rant>

https://codereview.chromium.org/1351373002/diff/1/base/memory/shared_memory_w...
base/memory/shared_memory_win.cc:87: DCHECK(IsHandleValid(handle));
ScopedHandle closer(handle);

<rant> receiving const SharedHandle& for something that we'll be essentially
destroying doesn't make sense to me. This method also has to go away </rant>

https://codereview.chromium.org/1351373002/diff/1/base/memory/shared_memory_w...
base/memory/shared_memory_win.cc:181: DCHECK(!IsHandleValid(mapped_file_));
DCHECK(mapped_file_.Isvalid());

(+ making the member a ScopedHandle). etc.

Powered by Google App Engine
This is Rietveld 408576698