2016-07-27 20:44:29 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2020-01-20 19:18:20 +03:00
|
|
|
#include <utility>
|
2017-10-10 13:06:35 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
2017-08-29 00:16:20 +03:00
|
|
|
# include "HandlerData.h"
|
|
|
|
# include "mozilla/a11y/Platform.h"
|
|
|
|
# include "mozilla/mscom/ActivationContext.h"
|
2017-10-10 13:06:35 +03:00
|
|
|
#endif // defined(ACCESSIBILITY)
|
2016-07-27 20:44:29 +03:00
|
|
|
#include "mozilla/mscom/EnsureMTA.h"
|
|
|
|
#include "mozilla/mscom/ProxyStream.h"
|
2016-08-30 04:55:37 +03:00
|
|
|
#include "mozilla/mscom/Utils.h"
|
2017-09-30 00:41:28 +03:00
|
|
|
#include "mozilla/ScopeExit.h"
|
2017-03-03 21:33:13 +03:00
|
|
|
|
2017-08-29 00:16:20 +03:00
|
|
|
#include "mozilla/mscom/Objref.h"
|
2017-02-27 21:55:42 +03:00
|
|
|
#include "nsExceptionHandler.h"
|
2017-05-12 00:22:19 +03:00
|
|
|
#include "nsPrintfCString.h"
|
2017-08-29 00:16:20 +03:00
|
|
|
#include "RegistrationAnnotator.h"
|
2016-07-27 20:44:29 +03:00
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <objbase.h>
|
|
|
|
#include <shlwapi.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace mscom {
|
|
|
|
|
|
|
|
ProxyStream::ProxyStream()
|
|
|
|
: mGlobalLockedBuf(nullptr),
|
|
|
|
mHGlobal(nullptr),
|
|
|
|
mBufSize(0),
|
2017-08-17 01:31:07 +03:00
|
|
|
mPreserveStream(false) {}
|
2016-07-27 20:44:29 +03:00
|
|
|
|
|
|
|
// GetBuffer() fails with this variant, but that's okay because we're just
|
|
|
|
// reconstructing the stream from a buffer anyway.
|
2017-05-19 22:59:49 +03:00
|
|
|
ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf,
|
2017-09-30 00:41:28 +03:00
|
|
|
const int aInitBufSize, Environment* aEnv)
|
2017-08-22 19:48:12 +03:00
|
|
|
: mGlobalLockedBuf(nullptr),
|
2016-07-27 20:44:29 +03:00
|
|
|
mHGlobal(nullptr),
|
|
|
|
mBufSize(aInitBufSize),
|
2017-08-17 01:31:07 +03:00
|
|
|
mPreserveStream(false) {
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::Annotation kCrashReportKey =
|
|
|
|
CrashReporter::Annotation::ProxyStreamUnmarshalStatus;
|
2017-08-10 00:07:11 +03:00
|
|
|
|
2017-09-06 19:38:13 +03:00
|
|
|
if (!aInitBufSize) {
|
2020-07-01 11:29:29 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(kCrashReportKey, "!aInitBufSize"_ns);
|
2017-09-06 19:38:13 +03:00
|
|
|
// We marshaled a nullptr. Nothing else to do here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-22 19:48:12 +03:00
|
|
|
HRESULT createStreamResult =
|
|
|
|
CreateStream(aInitBuf, aInitBufSize, getter_AddRefs(mStream));
|
|
|
|
if (FAILED(createStreamResult)) {
|
|
|
|
nsPrintfCString hrAsStr("0x%08X", createStreamResult);
|
|
|
|
CrashReporter::AnnotateCrashReport(kCrashReportKey, hrAsStr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-27 20:44:29 +03:00
|
|
|
// NB: We can't check for a null mStream until after we have checked for
|
|
|
|
// the zero aInitBufSize above. This is because InitStream will also fail
|
|
|
|
// in that case, even though marshaling a nullptr is allowable.
|
|
|
|
MOZ_ASSERT(mStream);
|
|
|
|
if (!mStream) {
|
2020-07-01 11:29:29 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(kCrashReportKey, "!mStream"_ns);
|
2016-07-27 20:44:29 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-10 13:06:35 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
2017-08-29 00:16:20 +03:00
|
|
|
const uint32_t expectedStreamLen = GetOBJREFSize(WrapNotNull(mStream));
|
|
|
|
nsAutoCString strActCtx;
|
2017-09-19 23:35:27 +03:00
|
|
|
nsAutoString manifestPath;
|
2017-10-10 13:06:35 +03:00
|
|
|
#endif // defined(ACCESSIBILITY)
|
2017-08-29 00:16:20 +03:00
|
|
|
|
2017-05-19 22:59:49 +03:00
|
|
|
HRESULT unmarshalResult = S_OK;
|
|
|
|
|
2016-07-27 20:44:29 +03:00
|
|
|
// We need to convert to an interface here otherwise we mess up const
|
|
|
|
// correctness with IPDL. We'll request an IUnknown and then QI the
|
|
|
|
// actual interface later.
|
|
|
|
|
2017-10-10 13:06:35 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
2017-09-30 00:41:28 +03:00
|
|
|
auto marshalFn = [this, &strActCtx, &manifestPath, &unmarshalResult, &aIID,
|
|
|
|
aEnv]() -> void
|
2017-08-28 21:27:28 +03:00
|
|
|
#else
|
2017-09-30 00:41:28 +03:00
|
|
|
auto marshalFn = [this, &unmarshalResult, &aIID, aEnv]() -> void
|
2017-10-10 13:06:35 +03:00
|
|
|
#endif // defined(ACCESSIBILITY)
|
2016-07-27 20:44:29 +03:00
|
|
|
{
|
2017-09-30 00:41:28 +03:00
|
|
|
if (aEnv) {
|
|
|
|
bool pushOk = aEnv->Push();
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(pushOk);
|
|
|
|
if (!pushOk) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto popEnv = MakeScopeExit([aEnv]() -> void {
|
|
|
|
if (!aEnv) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-05 23:18:48 +03:00
|
|
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
|
|
|
bool popOk =
|
|
|
|
#endif
|
|
|
|
aEnv->Pop();
|
2017-09-30 00:41:28 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(popOk);
|
|
|
|
});
|
|
|
|
|
2017-10-10 13:06:35 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
2017-08-29 00:16:20 +03:00
|
|
|
auto curActCtx = ActivationContext::GetCurrent();
|
|
|
|
if (curActCtx.isOk()) {
|
|
|
|
strActCtx.AppendPrintf("0x%p", curActCtx.unwrap());
|
|
|
|
} else {
|
|
|
|
strActCtx.AppendPrintf("HRESULT 0x%08X", curActCtx.unwrapErr());
|
|
|
|
}
|
2017-09-19 23:35:27 +03:00
|
|
|
|
|
|
|
ActivationContext::GetCurrentManifestPath(manifestPath);
|
2017-10-10 13:06:35 +03:00
|
|
|
#endif // defined(ACCESSIBILITY)
|
2017-08-29 00:16:20 +03:00
|
|
|
|
|
|
|
unmarshalResult = ::CoUnmarshalInterface(mStream, aIID,
|
|
|
|
getter_AddRefs(mUnmarshaledProxy));
|
2017-05-19 22:59:49 +03:00
|
|
|
MOZ_ASSERT(SUCCEEDED(unmarshalResult));
|
2016-07-27 20:44:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
// We'll marshal this stuff directly using the current thread, therefore its
|
|
|
|
// proxy will reside in the same apartment as the current thread.
|
|
|
|
marshalFn();
|
|
|
|
} else {
|
|
|
|
// When marshaling in child processes, we want to force the MTA.
|
|
|
|
EnsureMTA mta(marshalFn);
|
|
|
|
}
|
2017-02-27 21:55:42 +03:00
|
|
|
|
2017-08-29 00:16:20 +03:00
|
|
|
mStream = nullptr;
|
|
|
|
|
|
|
|
if (FAILED(unmarshalResult) || !mUnmarshaledProxy) {
|
2017-05-19 22:59:49 +03:00
|
|
|
nsPrintfCString hrAsStr("0x%08X", unmarshalResult);
|
2017-02-27 21:55:42 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::Annotation::CoUnmarshalInterfaceResult, hrAsStr);
|
2017-05-19 22:59:49 +03:00
|
|
|
AnnotateInterfaceRegistration(aIID);
|
2017-08-31 20:31:28 +03:00
|
|
|
if (!mUnmarshaledProxy) {
|
2020-07-01 11:29:29 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(kCrashReportKey,
|
|
|
|
"!mUnmarshaledProxy"_ns);
|
2017-08-31 20:31:28 +03:00
|
|
|
}
|
|
|
|
|
2017-08-29 00:16:20 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
|
|
|
AnnotateClassRegistration(CLSID_AccessibleHandler);
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::UnmarshalActCtx, strActCtx);
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::UnmarshalActCtxManifestPath,
|
|
|
|
NS_ConvertUTF16toUTF8(manifestPath));
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::A11yHandlerRegistered,
|
2020-07-01 11:29:29 +03:00
|
|
|
a11y::IsHandlerRegistered() ? "true"_ns : "false"_ns);
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::ExpectedStreamLen, expectedStreamLen);
|
|
|
|
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::ActualStreamLen, aInitBufSize);
|
2017-08-29 00:16:20 +03:00
|
|
|
#endif // defined(ACCESSIBILITY)
|
2017-02-27 21:55:42 +03:00
|
|
|
}
|
2016-07-27 20:44:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ProxyStream::ProxyStream(ProxyStream&& aOther)
|
2017-08-10 00:07:11 +03:00
|
|
|
: mGlobalLockedBuf(nullptr),
|
|
|
|
mHGlobal(nullptr),
|
|
|
|
mBufSize(0),
|
2017-08-17 01:31:07 +03:00
|
|
|
mPreserveStream(false) {
|
2018-05-30 22:15:35 +03:00
|
|
|
*this = std::move(aOther);
|
2016-07-27 20:44:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ProxyStream& ProxyStream::operator=(ProxyStream&& aOther) {
|
2017-08-10 00:07:11 +03:00
|
|
|
if (mHGlobal && mGlobalLockedBuf) {
|
|
|
|
DebugOnly<BOOL> result = ::GlobalUnlock(mHGlobal);
|
|
|
|
MOZ_ASSERT(!result && ::GetLastError() == NO_ERROR);
|
|
|
|
}
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
mStream = std::move(aOther.mStream);
|
2017-08-10 00:07:11 +03:00
|
|
|
|
2016-07-27 20:44:29 +03:00
|
|
|
mGlobalLockedBuf = aOther.mGlobalLockedBuf;
|
|
|
|
aOther.mGlobalLockedBuf = nullptr;
|
2017-08-10 00:07:11 +03:00
|
|
|
|
|
|
|
// ::GlobalFree() was called implicitly when mStream was replaced.
|
2016-07-27 20:44:29 +03:00
|
|
|
mHGlobal = aOther.mHGlobal;
|
|
|
|
aOther.mHGlobal = nullptr;
|
2017-08-10 00:07:11 +03:00
|
|
|
|
2016-07-27 20:44:29 +03:00
|
|
|
mBufSize = aOther.mBufSize;
|
|
|
|
aOther.mBufSize = 0;
|
2017-08-10 00:07:11 +03:00
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
mUnmarshaledProxy = std::move(aOther.mUnmarshaledProxy);
|
2017-08-17 01:31:07 +03:00
|
|
|
|
|
|
|
mPreserveStream = aOther.mPreserveStream;
|
2016-07-27 20:44:29 +03:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProxyStream::~ProxyStream() {
|
|
|
|
if (mHGlobal && mGlobalLockedBuf) {
|
|
|
|
DebugOnly<BOOL> result = ::GlobalUnlock(mHGlobal);
|
|
|
|
MOZ_ASSERT(!result && ::GetLastError() == NO_ERROR);
|
|
|
|
// ::GlobalFree() is called implicitly when mStream is released
|
|
|
|
}
|
2017-08-17 01:31:07 +03:00
|
|
|
|
|
|
|
// If this assert triggers then we will be leaking a marshaled proxy!
|
|
|
|
// Call GetPreservedStream to obtain a preservable stream and then save it
|
|
|
|
// until the proxy is no longer needed.
|
|
|
|
MOZ_ASSERT(!mPreserveStream);
|
2016-07-27 20:44:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const BYTE* ProxyStream::GetBuffer(int& aReturnedBufSize) const {
|
|
|
|
aReturnedBufSize = 0;
|
|
|
|
if (!mStream) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (!mGlobalLockedBuf) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
aReturnedBufSize = mBufSize;
|
|
|
|
return mGlobalLockedBuf;
|
|
|
|
}
|
|
|
|
|
2017-08-17 01:31:07 +03:00
|
|
|
PreservedStreamPtr ProxyStream::GetPreservedStream() {
|
2017-07-19 21:07:45 +03:00
|
|
|
MOZ_ASSERT(mStream);
|
|
|
|
MOZ_ASSERT(mHGlobal);
|
|
|
|
|
2017-08-17 01:31:07 +03:00
|
|
|
if (!mStream || !mPreserveStream) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clone the stream so that the result has a distinct seek pointer.
|
|
|
|
RefPtr<IStream> cloned;
|
|
|
|
HRESULT hr = mStream->Clone(getter_AddRefs(cloned));
|
|
|
|
if (FAILED(hr)) {
|
2017-07-19 21:07:45 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure the stream is rewound. We do this because CoReleaseMarshalData needs
|
|
|
|
// the stream to be pointing to the beginning of the marshal data.
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
pos.QuadPart = 0LL;
|
2017-08-17 01:31:07 +03:00
|
|
|
hr = cloned->Seek(pos, STREAM_SEEK_SET, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-07-19 21:07:45 +03:00
|
|
|
|
2017-08-17 01:31:07 +03:00
|
|
|
mPreserveStream = false;
|
2018-05-30 22:15:35 +03:00
|
|
|
return ToPreservedStreamPtr(std::move(cloned));
|
2017-07-19 21:07:45 +03:00
|
|
|
}
|
|
|
|
|
2017-07-13 00:00:27 +03:00
|
|
|
bool ProxyStream::GetInterface(void** aOutInterface) {
|
2016-07-27 20:44:29 +03:00
|
|
|
// We should not have a locked buffer on this side
|
|
|
|
MOZ_ASSERT(!mGlobalLockedBuf);
|
|
|
|
MOZ_ASSERT(aOutInterface);
|
|
|
|
|
|
|
|
if (!aOutInterface) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-13 00:00:27 +03:00
|
|
|
*aOutInterface = mUnmarshaledProxy.release();
|
|
|
|
return true;
|
2016-07-27 20:44:29 +03:00
|
|
|
}
|
|
|
|
|
2017-09-30 00:41:28 +03:00
|
|
|
ProxyStream::ProxyStream(REFIID aIID, IUnknown* aObject, Environment* aEnv,
|
2017-08-17 01:31:07 +03:00
|
|
|
ProxyStreamFlags aFlags)
|
2016-07-27 20:44:29 +03:00
|
|
|
: mGlobalLockedBuf(nullptr),
|
|
|
|
mHGlobal(nullptr),
|
|
|
|
mBufSize(0),
|
2017-08-17 01:31:07 +03:00
|
|
|
mPreserveStream(aFlags & ProxyStreamFlags::ePreservable) {
|
2017-03-15 03:42:24 +03:00
|
|
|
if (!aObject) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-27 20:44:29 +03:00
|
|
|
RefPtr<IStream> stream;
|
|
|
|
HGLOBAL hglobal = NULL;
|
2017-03-15 03:42:24 +03:00
|
|
|
int streamSize = 0;
|
2017-08-17 01:31:07 +03:00
|
|
|
DWORD mshlFlags = mPreserveStream ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_NORMAL;
|
2016-07-27 20:44:29 +03:00
|
|
|
|
2017-08-10 00:07:11 +03:00
|
|
|
HRESULT createStreamResult = S_OK;
|
2017-02-27 21:55:42 +03:00
|
|
|
HRESULT marshalResult = S_OK;
|
2017-08-10 00:07:11 +03:00
|
|
|
HRESULT statResult = S_OK;
|
|
|
|
HRESULT getHGlobalResult = S_OK;
|
2017-02-27 21:55:42 +03:00
|
|
|
|
2017-09-19 23:35:27 +03:00
|
|
|
nsAutoString manifestPath;
|
|
|
|
|
2018-10-10 07:31:35 +03:00
|
|
|
auto marshalFn = [&aIID, aObject, mshlFlags, &stream, &streamSize, &hglobal,
|
2017-09-19 23:35:27 +03:00
|
|
|
&createStreamResult, &marshalResult, &statResult,
|
2017-09-30 00:41:28 +03:00
|
|
|
&getHGlobalResult, aEnv, &manifestPath]() -> void {
|
|
|
|
if (aEnv) {
|
|
|
|
bool pushOk = aEnv->Push();
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(pushOk);
|
|
|
|
if (!pushOk) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto popEnv = MakeScopeExit([aEnv]() -> void {
|
|
|
|
if (!aEnv) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-05 23:18:48 +03:00
|
|
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
|
|
|
bool popOk =
|
|
|
|
#endif
|
|
|
|
aEnv->Pop();
|
2017-09-30 00:41:28 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(popOk);
|
|
|
|
});
|
|
|
|
|
2017-09-19 23:35:27 +03:00
|
|
|
createStreamResult =
|
|
|
|
::CreateStreamOnHGlobal(nullptr, TRUE, getter_AddRefs(stream));
|
2017-08-10 00:07:11 +03:00
|
|
|
if (FAILED(createStreamResult)) {
|
2016-07-27 20:44:29 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-10 13:06:35 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
2017-09-19 23:35:27 +03:00
|
|
|
ActivationContext::GetCurrentManifestPath(manifestPath);
|
2017-10-10 13:06:35 +03:00
|
|
|
#endif // defined(ACCESSIBILITY)
|
2017-09-19 23:35:27 +03:00
|
|
|
|
2017-08-10 00:07:11 +03:00
|
|
|
marshalResult = ::CoMarshalInterface(stream, aIID, aObject, MSHCTX_LOCAL,
|
2017-08-17 01:31:07 +03:00
|
|
|
nullptr, mshlFlags);
|
2018-03-23 22:21:56 +03:00
|
|
|
MOZ_ASSERT(marshalResult != E_INVALIDARG);
|
2017-08-10 00:07:11 +03:00
|
|
|
if (FAILED(marshalResult)) {
|
2016-07-27 20:44:29 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-15 03:42:24 +03:00
|
|
|
STATSTG statstg;
|
2017-08-10 00:07:11 +03:00
|
|
|
statResult = stream->Stat(&statstg, STATFLAG_NONAME);
|
|
|
|
if (SUCCEEDED(statResult)) {
|
2017-03-15 03:42:24 +03:00
|
|
|
streamSize = static_cast<int>(statstg.cbSize.LowPart);
|
2017-08-10 00:07:11 +03:00
|
|
|
} else {
|
|
|
|
return;
|
2017-03-15 03:42:24 +03:00
|
|
|
}
|
|
|
|
|
2017-08-10 00:07:11 +03:00
|
|
|
getHGlobalResult = ::GetHGlobalFromStream(stream, &hglobal);
|
|
|
|
MOZ_ASSERT(SUCCEEDED(getHGlobalResult));
|
2016-07-27 20:44:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
// We'll marshal this stuff directly using the current thread, therefore its
|
|
|
|
// stub will reside in the same apartment as the current thread.
|
|
|
|
marshalFn();
|
|
|
|
} else {
|
|
|
|
// When marshaling in child processes, we want to force the MTA.
|
|
|
|
EnsureMTA mta(marshalFn);
|
|
|
|
}
|
|
|
|
|
2017-08-10 00:07:11 +03:00
|
|
|
if (FAILED(createStreamResult)) {
|
|
|
|
nsPrintfCString hrAsStr("0x%08X", createStreamResult);
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::Annotation::CreateStreamOnHGlobalFailure, hrAsStr);
|
2017-08-10 00:07:11 +03:00
|
|
|
}
|
|
|
|
|
2017-02-27 21:55:42 +03:00
|
|
|
if (FAILED(marshalResult)) {
|
2017-05-05 00:41:35 +03:00
|
|
|
AnnotateInterfaceRegistration(aIID);
|
2017-02-27 21:55:42 +03:00
|
|
|
nsPrintfCString hrAsStr("0x%08X", marshalResult);
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::Annotation::CoMarshalInterfaceFailure, hrAsStr);
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::MarshalActCtxManifestPath,
|
|
|
|
NS_ConvertUTF16toUTF8(manifestPath));
|
2017-02-27 21:55:42 +03:00
|
|
|
}
|
2017-08-10 00:07:11 +03:00
|
|
|
|
|
|
|
if (FAILED(statResult)) {
|
|
|
|
nsPrintfCString hrAsStr("0x%08X", statResult);
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::StatFailure,
|
|
|
|
hrAsStr);
|
2017-08-10 00:07:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(getHGlobalResult)) {
|
|
|
|
nsPrintfCString hrAsStr("0x%08X", getHGlobalResult);
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::Annotation::GetHGlobalFromStreamFailure, hrAsStr);
|
2017-08-10 00:07:11 +03:00
|
|
|
}
|
2017-02-27 21:55:42 +03:00
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
mStream = std::move(stream);
|
2017-03-15 03:42:24 +03:00
|
|
|
|
2017-08-10 00:07:11 +03:00
|
|
|
if (streamSize) {
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(
|
2020-07-01 11:29:29 +03:00
|
|
|
CrashReporter::Annotation::ProxyStreamSizeFrom, "IStream::Stat"_ns);
|
2017-08-10 00:07:11 +03:00
|
|
|
mBufSize = streamSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hglobal) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGlobalLockedBuf = reinterpret_cast<BYTE*>(::GlobalLock(hglobal));
|
|
|
|
mHGlobal = hglobal;
|
2017-03-15 03:42:24 +03:00
|
|
|
|
2017-08-10 00:07:11 +03:00
|
|
|
// If we couldn't get the stream size directly from mStream, we may use
|
|
|
|
// the size of the memory block allocated by the HGLOBAL, though it might
|
|
|
|
// be larger than the actual stream size.
|
|
|
|
if (!streamSize) {
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(
|
2020-07-01 11:29:29 +03:00
|
|
|
CrashReporter::Annotation::ProxyStreamSizeFrom, "GlobalSize"_ns);
|
2017-08-10 00:07:11 +03:00
|
|
|
mBufSize = static_cast<int>(::GlobalSize(hglobal));
|
2016-07-27 20:44:29 +03:00
|
|
|
}
|
2017-08-10 00:07:11 +03:00
|
|
|
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::ProxyStreamSize,
|
|
|
|
mBufSize);
|
2016-07-27 20:44:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mscom
|
|
|
|
} // namespace mozilla
|