2389 Commits

Author SHA1 Message Date
Scott Graham
3eeae10ebe win: avoid warning on return of base::RandGenerator
Else,

d:\src\crashpad\crashpad\util\net\http_multipart_builder.cc(50) : warning C4244: 'initializing' : conversion from 'uint64_t' to 'int', possible loss of data

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/796643006
2014-12-17 10:50:05 -08:00
Scott Graham
db6492e154 win: clock implementation
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807973002
2014-12-17 10:45:43 -08:00
Mark Mentovai
86cf286350 Update mini_chromium to 158694255c7a.
This picks up:

158694255c7a win: undef ERROR, causing failing LOGs
3a981db6e6df MSVC: Disable “warning C4702: unreachable code”.
e87cd9d4dff5 Tidy string16.h after
             https://codereview.chromium.org/809563003/

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/812683002
2014-12-16 17:12:30 -05:00
Scott Graham
4a5d21528e DCHECK_LE for cr_ngroups vs arraysize(cr_groups)
This DCHECK fails for me locally as

[----------] 3 tests from ProcessInfo
[ RUN      ] ProcessInfo.Self
[70989:10546846:20141216,112509.948519:FATAL process_info_mac.cc:114] Check failed: static_cast<size_t>(ngroups) < (sizeof(ArraySizeHelper(kern_proc_info_.kp_eproc.e_ucred.cr_groups))) (16 vs. 16).
Abort trap: 6

It doesn't seem to happen on the waterfall, so maybe I'm building against
an incorrect header? I don't particularly understand the code, but assuming
it's normal 0-based array, perhaps it should be a DCHECK_LE in any case.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/813473002
2014-12-16 12:18:32 -08:00
Mark Mentovai
5adfa5039e string_number_conversions: only check CXX_LIBRARY_HAS_CONSTEXPR.
CXX_LIBRARY_VERSION is irrelevant, because the only C++11 library
feature of any concern is whether numeric_limits’ min() and max() are
declared constexpr.

Crashpad is C++11-only as far as the language is concerned, and the
comment doesn’t need to call it out explicitly because static_assert()
is always available.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/809833002
2014-12-16 14:55:28 -05:00
Mark Mentovai
d78b003ef1 Add NotifyServer and its test.
TEST=util_test NotifyServerTest.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/804633002
2014-12-16 14:10:16 -05:00
Scott Graham
4263334db8 win: avoid warnings in string_number_conversion_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807463004
2014-12-16 11:00:20 -08:00
Scott Graham
b0cf01978d win: Get client/crashpad_info.cc to compile
Just avoid the Mac-specific __attribute__ tagging for now. There will need
to be some Windows-specific pragmas added here once the reader has been
written.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/808623002
2014-12-16 10:22:41 -08:00
Scott Graham
086714261a Roll mini_chromium to 2ef83a609517f284096f7e8296b0915d634c3ca7
Pick up build fix.

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/804853004
2014-12-15 16:46:46 -08:00
Scott Graham
7941e7f955 Roll mini_chromium to 463f840...
To pull in string16 changes.

TBR=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/811613002
2014-12-15 16:31:15 -08:00
Scott Graham
9d38069f13 win: static_cast to uint64_t rather than implicit_cast, to avoid warnings
e.g.

FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\util\misc\util_test.clock_test.obj.rsp /c ..\..\util\misc\clock_test.cc /Foobj\util\misc\util_test.clock_test.obj /Fdobj\util\util_test.cc.pdb
d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(49) : error C2220: warning treated as error - no 'object' file generated
        d:\src\crashpad\crashpad\util\misc\clock_test.cc(72) : see reference to function template instantiation 'To implicit_cast<uint64_t,double>(const From &)' being compiled
        with
        [
            To=uint64_t
,            From=double
        ]
d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(49) : warning C4244: 'return' : conversion from 'const double' to 'uint64_t', possible loss of data

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807653002
2014-12-15 16:21:12 -08:00
Scott Graham
1a17e7e643 win: Avoid warnings about conversion to smaller integer types
e.g.

d:\src\crashpad\crashpad\util\numeric\in_range_cast.h(35) : warning C4244: 'return' : conversion from 'unsigned __int64' to 'uint32_t', possible loss of data
d:\src\crashpad\crashpad\util\numeric\in_range_cast.h(35) : warning C4244: 'return' : conversion from '__int64' to 'int32_t', possible loss of data
        d:\src\crashpad\crashpad\util\numeric\in_range_cast_test.cc(54) : see reference to function template instantiation 'Destination crashpad::InRangeCast<int32_t,__int64>(Source,Destination)' being compiled
        with
        [
            Destination=int32_t
,            Source=__int64
        ]

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/800073003
2014-12-15 16:19:33 -08:00
Scott Graham
e8ab9afd82 win: Avoid 'warning C4068: unknown pragma'
I could also add COMPILER_CLANG to build_config.h, but that doesn't
appear in Chromium, apparently in preference to using __clang__
directly. I'm not sure if there's any good reason for that.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/803283002
2014-12-15 16:01:16 -08:00
Scott Graham
c23dcdc88a win: set CXX_LIBRARY_VERSION to 2011
Unfortunately VS2013's support of C++11 is partial. It supports the
extended union definition, but does not fully support constexpr.

So, update some locations where CXX_LIBRARY_VERSION is used where
toolchain support is lacking. It works correctly in the locations
where std::is_standard_layout is used.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/803273002
2014-12-15 15:55:41 -08:00
Mark Mentovai
22cf9e28d5 util_test: Don’t crash when run from the wrong location.
When run from the wrong location and test data or other test programs
can’t be found, the tests should fail with gtest assertions. The test
executable should not crash.

BUG=crashpad:4
TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/799083003
2014-12-15 16:40:16 -05:00
Mark Mentovai
554e75422c MachMessageServer::Interface implementations: minor cleanups.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/799463003
2014-12-15 14:47:47 -05:00
Mark Mentovai
dc22dc405d Fix run_tests to always run from the crashpad directory.
BUG=4
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/799073002
2014-12-12 17:16:11 -05:00
Scott Graham
5c59a1fa18 Roll mini_chromium to 001bf11...
And another roll to get to mini_chromium to HEAD.

R=mark@chromium.org
TBR=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/799923005
2014-12-12 12:23:42 -08:00
Scott Graham
8d0e213213 Add test runner script for integration with the waterfall
R=mark@chromium.org

Review URL: https://codereview.chromium.org/800983002
2014-12-12 11:48:42 -08:00
Scott Graham
af07f4022b Move string16 and char16 in to base::
Needs to include roll with https://codereview.chromium.org/803593002/ included.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/804593002
2014-12-12 11:06:09 -08:00
Scott Graham
1c4084fc2d Roll mini_chromium to 9427a67...
To pick up progress on compiling base on Windows.

TBR=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/790343004
2014-12-11 16:31:40 -08:00
Scott Graham
f721df692e Revert 'Roll mini_chromium DEPS to a1fa3c5...'
mini_chromium rev broken, will fix and re-roll.

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/797553003
2014-12-11 14:41:51 -08:00
Scott Graham
c46dd63762 Roll mini_chromium DEPS to a1fa3c5...
Want to roll the mini_chromium changes in little chunks as the bot
doesn't otherwise build them, to avoid leaving something broken
for a while.

R=mark@chromium.org
TBR=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/796113002
2014-12-11 14:33:34 -08:00
Mark Mentovai
508a33dc7a exc_server_variants: Templatize and use CompositeMachMessageServer.
The implementations for the exc and mach_exc subsystems were nearly
identical, and were a good target for templatization. The existing
split between exc and mach_exc was a good candidate for unification
based on CompositeMachMessageServer instead of the custom unification
previously done in UniversalMachMessageServer.

TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/766193006
2014-12-11 14:29:42 -05:00
Mark Mentovai
302c87c6e5 Use GYP rules instead of actions to run mig.
TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/793323003
2014-12-11 11:27:18 -05:00
Scott Graham
012ddc9752 win: Add compat header for sys/types.h
To add definition of ssize_t. Uses #include <../include/...> to
emulate #include_next, similar to the mac headers.

BUG=crashpad:1
R=mark@chromium.org

Review URL: https://codereview.chromium.org/793013002
2014-12-10 11:39:50 -08:00
Mark Mentovai
c874958fd0 MachMessageServer: eliminate argument redundancy.
MachMessageServer::Run()’s distinct |nonblocking| parameter is removed.
The information it formerly conveyed is now implied by the |timeout_ms|
parameter, which can accept two special values,
kMachMessageTimeoutNonblocking and kMachMessageTimeoutWaitIndefinitely.

TEST=client_test, snapshot_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/777993002
2014-12-10 11:11:21 -05:00
Mark Mentovai
22b2f0cad7 tools: Use hyphens instead of underscores for multi-word option names.
Option names like --mach-service are easier to type than --mach_service.
Command-line tools don’t necessarily have the most ergonomic interfaces
anyway, but this is an improvement.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/774763006
2014-12-04 16:46:12 -05:00
Mark Mentovai
c83e773c33 Add CompositeMachMessageServer and its test.
TEST=util_test CompositeMachMessageServer*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/781823002
2014-12-04 16:45:02 -05:00
Mark Mentovai
821ed8fe0f UniversalMachExcServer: eliminate multiple implementation inheritance.
UniversalMachExcServer provided both an interface and an implementation,
contrary to the other classes in the exc_server_variants family. This
was mostly done for reasons of economy in an already-large class family.
Unfortunately, this decision meant that it was impossible for other code
to use UniversalMachExcServer, which required that CatchMachException()
be implemented, and also extend another class without violating the
style guide’s prohibition of multiple implementation inheritance. This
became a problem in a lot of test code, which extended MachMultiprocess
and UniversalMachExcServer.

UniversalMachExcServer is now given its own nested Interface class,
which is a pure interface. All users of UniversalMachExcServer are
changed from “is-a” UniversalMachExcServer to “has-a”
UniversalMachExcServer and “is-a” UniversalMachExcServer::Interface.

TEST=client_test, snapshot_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/775943005
2014-12-04 10:18:24 -05:00
Mark Mentovai
86588c5526 MachMessageServer: scribble over memory allocations in debug mode.
This exposed a bug in the ExcClientVariants test, which was expecting
the memory used for new_state to be initialized with zeroes. In reality,
no guarantee of initialization is made. MIG “out” parameters are
strictly “out” and may contain garbage at function entry.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/779633004
2014-12-03 18:24:27 -05:00
Mark Mentovai
9f520e3fbf MachMessageServer: add some DCHECKs.
These DCHECKs make sure that buffer sizes and message sizes are as
expected.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/781593003
2014-12-03 18:21:00 -05:00
Mark Mentovai
ef0b7cf6d5 Rewrite MachMessageServer::Run().
This method is now much more straightforward, easy to understand, and
maintainable.

There are no externally-visible changes.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/723853003
2014-12-03 16:45:48 -05:00
Mark Mentovai
8593b1aa55 ChildPortHandshake: 10.6 fix.
The F_SETNOSIGPIPE fcntl() command is not available on 10.6. Use
socketpair() instead of pipe(), so that the SO_NOSIGPIPE socket option
can be used.

TEST=util_test ChildPortHandshake.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/777573002
2014-12-03 13:42:06 -05:00
Mark Mentovai
eee9de7361 MachMessageWithDeadline(): 10.6 SDK fix.
In the pre-C++11 10.6 SDK, std::numeric_limits<>::max() is not marked
constexpr and cannot be used to initialize enum elements.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/771183003
2014-12-02 18:37:31 -05:00
Mark Mentovai
dce497446e Add MachMessageWithDeadline() and supporting characters.
MachMessageWithDeadline() is a mach_msg() wrapper that deals with
deadlines instead of timeouts. It is a slight simplification of the
mach_msg() interface because the deadline parameter implies the timeout
option bits, and because the caller does not need to specify send_size
during sends as the message itself already carries this information.

TEST=util_test MachMessage.MachMessageDeadlineFromTimeout
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/773943002
2014-12-02 17:09:08 -05:00
Mark Mentovai
c0d5d87785 Move mach_message_util.* to mach_message.*.
A subsequent change will add MachMessageWithDeadline(), a mach_msg()
wrapper. Conceptually, it makes sense to include that function in this
file family. Since this file family now contains a mach_msg() wrapper,
it makes sense to rename it mach_message and lose the _util suffix.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/772133004
2014-12-02 17:02:32 -05:00
Mark Mentovai
49f170e633 MachMessageServer: handle allocations more reasonably.
MachMessageServer was wasteful with allocations for request and reply
messages. It allocated new memory for each request receive and for each
reply send, and if it needed to resize an allocation for a request, it
would maintain two request allocations simultaneously. The new behavior
allocates memory for a new request only if it needs a different size
than for the previous request, and it never maintains two request
allocations simultaneously. Memory for a reply is allocated once per
method invocation and maintained, since this never needs to be resized.

One pass of the loop is now guaranteed, even if a caller specifies a
very small timeout that expires before attempting to receive a message.

An infinite looping bug that could occur when ignoring large messages
has also been fixed.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/759023004
2014-12-01 16:13:40 -05:00
Mark Mentovai
50726ac8d0 Undo a68594234262.
The buffer sizing logic was correct to start with. I don’t know why I
misread it. It should say “if this would resize to receive a large
message, use the entire allocation rounded up to full page size,
otherwise, only use the space expected for a message.”

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/760573003
2014-12-01 16:12:10 -05:00
Mark Mentovai
0437bc53b6 Pass Mach message trailers to server handler functions.
TEST=util_test ChildPortServer.*:ExcServerVariants.*:MachMessageUtil.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/755313004
2014-12-01 16:06:56 -05:00
Mark Mentovai
de5a6cdd6f ExcServerVariants test: use constructors to initialize test structures.
Previously, test structures were initialized with InitializeForTesting()
methods. A related code review suggested making these into constructors.

https://codereview.chromium.org/754123002/diff/40001/util/mach/child_port_server_test.cc#newcode53

This also cleans up the definitions of some structures that can simply
inherit from existing structures defined in system headers.

TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/757113002
2014-11-25 15:06:42 -05:00
Mark Mentovai
d14fa0961a ExcServerVariants test: make the mock test port dispositions reflect reality.
These port dispositions were naïvely taken from excUser.c and
mach_excUser.c, but the local and remote portions were not swapped as
they would be upon receipt in a server. This swaps them to match how
they’d be visible in a server, and uses the port disposition name
aliases expected to be used in servers: MACH_MSG_TYPE_PORT_* instead of
MACH_MSG_TYPE_{MAKE,COPY,MOVE}_*.

TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/755323002
2014-11-25 15:05:29 -05:00
Mark Mentovai
a685942342 MachMessageServer: invert the request buffer allocation logic.
The existing implementation used the same logic as is found in
mach_msg_server(), but that logic seems incorrect. When the caller wants
to retry a mach_msg() receive of a too-large message that returns
MACH_RCV_TOO_LARGE, there’s no harm in attempting the receive with a
larger buffer initially. On the other hand, if the caller does not want
to retry such mach_msg() receive attempts, it’s an indication that the
caller is expecting to be intolerant of too-large messages, and there’s
no need to attempt the receive with a buffer any larger than requested.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/753363003
2014-11-25 15:04:31 -05:00
Mark Mentovai
306625dac4 MachMessageServer: don’t deal with MACH_SEND_TRAILER.
As documented, MACH_SEND_TRAILER would allow a sender to provide its own
message trailer instead of having the kernel append its own
kernel-generated trailer. This is a Mach feature that supports a network
of multiple Mach hosts, but even in that environment, the option is
restricted to use by privileged callers. In reality, MACH_SEND_TRAILER
has never been implemented in OS X.

The system’s mach_msg_server() family does consider the value of
MACH_SEND_TRAILER, but this is pointless. Any purported trailer set by a
server function would be ignored.

Maintaining this code gives the illusion that it’s functional, so it’s
being removed.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/736493007
2014-11-25 15:00:13 -05:00
Mark Mentovai
85c9318597 Add ChildPortHandshake and its test.
ChildPortHandshake is the most generic system yet to allow child
processes to provide their parents with Mach rights. These are
ordinarily expected to be send rights to the children’s own task ports,
or send rights to servers that the children hold receive rights to.

This updates DEPS to pull mini_chromium 1d3523dbda93, which includes
base::mac::ScopedMachPortSet.

TEST=util_test ChildPortHandshake.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/756603003
2014-11-25 14:56:05 -05:00
Mark Mentovai
79b4434c81 Add a ReceiveLarge parameter to MachMessageServer::Run().
Previously, MachMessageServer::Run() only provided two strategies for
dealing with large messages, indicated by mach_msg() returning
MACH_RCV_TOO_LARGE: the receive buffer could be reallocated and the
message received, or the entire function could return MACH_RCV_TOO_LARGE
to the caller. There are situations where an intermediate behavior might
be desirable. This intermediate behavior would allow the function to
continue waiting for another message without returning an error to the
caller or attempting to receive the large message. This is desirable
when dealing with fixed-sized messages and a receiver that might be sent
messages by unknown, possibly-malicious callers. This can happen when
the corresponding send right is published with the bootstrap server, for
example.

Existing users continue to request their existing behavior, typically
receiving an error when encountering a large message.
catch_exception_tool will use the new “ignore” behavior when running in
persistent mode.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/756803002
2014-11-25 14:48:44 -05:00
Mark Mentovai
04aaa36026 Add ChildPortServer, a MachMessageServer::Interface implementation for
the child_port subsystem.

Common routines shared with the ExcServer family of classes have been
moved to a new file, where they can be shared between different
MachMessageServer::Interface implementations.

TEST=util_test ChildPortServer.*:MachMessageUtil.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/754123002
2014-11-25 14:29:46 -05:00
Mark Mentovai
af1c7eb098 Add Logging{Read,Write}FD() and CheckedCloseFD().
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/756653004
2014-11-24 15:49:33 -05:00
Mark Mentovai
e9482a704d Add the child_port Mach subsystem.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/752243002
2014-11-24 15:48:10 -05:00
Mark Mentovai
e4551e709c exc_server_variants: use DISALLOW_COPY_AND_ASSIGN.
TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/753563003
2014-11-21 14:29:42 -05:00