Bug 1931877, part 2 - Replace 2 arg MOZ_DIAGNOSTIC_ASSERT(false) with MOZ_DIAGNOSTIC_CRASH. r=necko-reviewers,win-reviewers,glandium,rkraesig,valentin

Differential Revision: https://phabricator.services.mozilla.com/D229361
This commit is contained in:
Andrew McCreight 2024-11-20 16:37:50 +00:00
parent e239bce2c0
commit 67817a936e
40 changed files with 76 additions and 83 deletions

View File

@ -795,7 +795,7 @@ ipc::IPCResult DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
// This diagnostic assert and the one down below expect a well-behaved // This diagnostic assert and the one down below expect a well-behaved
// child process. In IPC fuzzing, we directly fuzz parameters of each // child process. In IPC fuzzing, we directly fuzz parameters of each
// method over IPDL and the asserts are not valid under these conditions. // method over IPDL and the asserts are not valid under these conditions.
MOZ_DIAGNOSTIC_ASSERT(false, "Binding to nonexistent proxy!"); MOZ_DIAGNOSTIC_CRASH("Binding to nonexistent proxy!");
#endif #endif
return IPC_FAIL(this, "binding to nonexistant proxy!"); return IPC_FAIL(this, "binding to nonexistant proxy!");
} }
@ -809,8 +809,7 @@ ipc::IPCResult DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
if (!outerDoc->IsOuterDoc() || outerDoc->ChildCount() > 1 || if (!outerDoc->IsOuterDoc() || outerDoc->ChildCount() > 1 ||
(outerDoc->ChildCount() == 1 && !outerDoc->RemoteChildAt(0)->IsDoc())) { (outerDoc->ChildCount() == 1 && !outerDoc->RemoteChildAt(0)->IsDoc())) {
#ifndef FUZZING_SNAPSHOT #ifndef FUZZING_SNAPSHOT
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("Binding to parent that isn't a valid OuterDoc!");
"Binding to parent that isn't a valid OuterDoc!");
#endif #endif
return IPC_FAIL(this, "Binding to parent that isn't a valid OuterDoc!"); return IPC_FAIL(this, "Binding to parent that isn't a valid OuterDoc!");
} }

View File

@ -1563,9 +1563,9 @@ JSObject* BrowsingContext::ReadStructuredClone(JSContext* aCx,
// Note: Do this check after reading our ID data. Returning null will abort // Note: Do this check after reading our ID data. Returning null will abort
// the decode operation anyway, but we should at least be as safe as possible. // the decode operation anyway, but we should at least be as safe as possible.
if (NS_WARN_IF(!NS_IsMainThread())) { if (NS_WARN_IF(!NS_IsMainThread())) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH(
"We shouldn't be trying to decode a BrowsingContext " "We shouldn't be trying to decode a BrowsingContext "
"on a background thread."); "on a background thread.");
return nullptr; return nullptr;
} }

View File

@ -3094,9 +3094,9 @@ already_AddRefed<nsIPrincipal> Document::MaybeDowngradePrincipal(
// extension principal, in the case of extension content scripts). // extension principal, in the case of extension content scripts).
auto* basePrin = BasePrincipal::Cast(aPrincipal); auto* basePrin = BasePrincipal::Cast(aPrincipal);
if (basePrin->Is<ExpandedPrincipal>()) { if (basePrin->Is<ExpandedPrincipal>()) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH(
"Should never try to create a document with " "Should never try to create a document with "
"an expanded principal"); "an expanded principal");
auto* expanded = basePrin->As<ExpandedPrincipal>(); auto* expanded = basePrin->As<ExpandedPrincipal>();
return do_AddRef(expanded->AllowList().LastElement()); return do_AddRef(expanded->AllowList().LastElement());

View File

@ -313,16 +313,14 @@ nsIGlobalObject::GetServiceWorkerContainer() {
RefPtr<ServiceWorker> nsIGlobalObject::GetOrCreateServiceWorker( RefPtr<ServiceWorker> nsIGlobalObject::GetOrCreateServiceWorker(
const ServiceWorkerDescriptor& aDescriptor) { const ServiceWorkerDescriptor& aDescriptor) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("this global should not have any service workers");
"this global should not have any service workers");
return nullptr; return nullptr;
} }
RefPtr<ServiceWorkerRegistration> nsIGlobalObject::GetServiceWorkerRegistration( RefPtr<ServiceWorkerRegistration> nsIGlobalObject::GetServiceWorkerRegistration(
const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor) const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor)
const { const {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("this global should not have any service workers");
"this global should not have any service workers");
return nullptr; return nullptr;
} }

View File

@ -3452,7 +3452,7 @@ mozilla::ipc::IPCResult ContentChild::RecvCrossProcessRedirect(
nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo( nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(
aArgs.loadInfo(), NOT_REMOTE_TYPE, getter_AddRefs(loadInfo)); aArgs.loadInfo(), NOT_REMOTE_TYPE, getter_AddRefs(loadInfo));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_DIAGNOSTIC_ASSERT(false, "LoadInfoArgsToLoadInfo failed"); MOZ_DIAGNOSTIC_CRASH("LoadInfoArgsToLoadInfo failed");
return IPC_OK(); return IPC_OK();
} }
@ -4224,7 +4224,7 @@ mozilla::ipc::IPCResult ContentChild::RecvReportFrameTimingData(
nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo( nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(
loadInfoArgs, NOT_REMOTE_TYPE, getter_AddRefs(loadInfo)); loadInfoArgs, NOT_REMOTE_TYPE, getter_AddRefs(loadInfo));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_DIAGNOSTIC_ASSERT(false, "LoadInfoArgsToLoadInfo failed"); MOZ_DIAGNOSTIC_CRASH("LoadInfoArgsToLoadInfo failed");
return IPC_OK(); return IPC_OK();
} }

View File

@ -196,7 +196,7 @@ size_t AudioConverter::DownmixAudio(void* aOut, const void* aIn,
dumbUpDownMix(static_cast<int16_t*>(aOut), outChannels, dumbUpDownMix(static_cast<int16_t*>(aOut), outChannels,
static_cast<const int16_t*>(aIn), inChannels, aFrames); static_cast<const int16_t*>(aIn), inChannels, aFrames);
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported data type"); MOZ_DIAGNOSTIC_CRASH("Unsupported data type");
} }
return aFrames; return aFrames;
} }
@ -312,7 +312,7 @@ size_t AudioConverter::DownmixAudio(void* aOut, const void* aIn,
} }
} }
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported data type"); MOZ_DIAGNOSTIC_CRASH("Unsupported data type");
} }
return aFrames; return aFrames;
} }
@ -337,7 +337,7 @@ size_t AudioConverter::DownmixAudio(void* aOut, const void* aIn,
*out++ = sample; *out++ = sample;
} }
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported data type"); MOZ_DIAGNOSTIC_CRASH("Unsupported data type");
} }
return aFrames; return aFrames;
} }
@ -362,7 +362,7 @@ size_t AudioConverter::ResampleAudio(void* aOut, const void* aIn,
error = speex_resampler_process_interleaved_int(mResampler, in, &inframes, error = speex_resampler_process_interleaved_int(mResampler, in, &inframes,
out, &outframes); out, &outframes);
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported data type"); MOZ_DIAGNOSTIC_CRASH("Unsupported data type");
error = RESAMPLER_ERR_ALLOC_FAILED; error = RESAMPLER_ERR_ALLOC_FAILED;
} }
MOZ_ASSERT(error == RESAMPLER_ERR_SUCCESS); MOZ_ASSERT(error == RESAMPLER_ERR_SUCCESS);
@ -425,7 +425,7 @@ size_t AudioConverter::UpmixAudio(void* aOut, const void* aIn,
dumbUpDownMix(static_cast<int16_t*>(aOut), mOut.Channels(), dumbUpDownMix(static_cast<int16_t*>(aOut), mOut.Channels(),
static_cast<const int16_t*>(aIn), mIn.Channels(), aFrames); static_cast<const int16_t*>(aIn), mIn.Channels(), aFrames);
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported data type"); MOZ_DIAGNOSTIC_CRASH("Unsupported data type");
} }
return aFrames; return aFrames;
} }
@ -454,7 +454,7 @@ size_t AudioConverter::UpmixAudio(void* aOut, const void* aIn,
*out++ = sample; *out++ = sample;
} }
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported data type"); MOZ_DIAGNOSTIC_CRASH("Unsupported data type");
} }
return aFrames; return aFrames;

View File

@ -348,7 +348,7 @@ class MediaDecoderStateMachine::DecodeMetadataState
RefPtr<MediaDecoder::SeekPromise> HandleSeek( RefPtr<MediaDecoder::SeekPromise> HandleSeek(
const SeekTarget& aTarget) override { const SeekTarget& aTarget) override {
MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata."); MOZ_DIAGNOSTIC_CRASH("Can't seek while decoding metadata.");
return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
} }
@ -2835,28 +2835,28 @@ class MediaDecoderStateMachine::ShutdownState
RefPtr<ShutdownPromise> Enter(); RefPtr<ShutdownPromise> Enter();
void Exit() override { void Exit() override {
MOZ_DIAGNOSTIC_ASSERT(false, "Shouldn't escape the SHUTDOWN state."); MOZ_DIAGNOSTIC_CRASH("Shouldn't escape the SHUTDOWN state.");
} }
State GetState() const override { return DECODER_STATE_SHUTDOWN; } State GetState() const override { return DECODER_STATE_SHUTDOWN; }
RefPtr<MediaDecoder::SeekPromise> HandleSeek( RefPtr<MediaDecoder::SeekPromise> HandleSeek(
const SeekTarget& aTarget) override { const SeekTarget& aTarget) override {
MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state."); MOZ_DIAGNOSTIC_CRASH("Can't seek in shutdown state.");
return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
} }
RefPtr<ShutdownPromise> HandleShutdown() override { RefPtr<ShutdownPromise> HandleShutdown() override {
MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down."); MOZ_DIAGNOSTIC_CRASH("Already shutting down.");
return nullptr; return nullptr;
} }
void HandleVideoSuspendTimeout() override { void HandleVideoSuspendTimeout() override {
MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down."); MOZ_DIAGNOSTIC_CRASH("Already shutting down.");
} }
void HandleResumeVideoDecoding(const TimeUnit&) override { void HandleResumeVideoDecoding(const TimeUnit&) override {
MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down."); MOZ_DIAGNOSTIC_CRASH("Already shutting down.");
} }
}; };

View File

@ -1401,9 +1401,9 @@ void MediaTrackGraphImpl::UpdateGraph(GraphTime aEndBlockingDecisions) {
MediaTimeToSeconds(track->GetEnd()), MediaTimeToSeconds(track->GetEnd()),
MediaTimeToSeconds( MediaTimeToSeconds(
track->GraphTimeToTrackTime(aEndBlockingDecisions)))); track->GraphTimeToTrackTime(aEndBlockingDecisions))));
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH(
"A non-ended SourceMediaTrack wasn't fed " "A non-ended SourceMediaTrack wasn't fed "
"enough data by NotifyPull"); "enough data by NotifyPull");
} }
} }
#endif /* MOZ_DIAGNOSTIC_ASSERT_ENABLED */ #endif /* MOZ_DIAGNOSTIC_ASSERT_ENABLED */

View File

@ -335,9 +335,9 @@ class VideoFrameConverterImpl {
rtc::scoped_refptr<webrtc::I420Buffer> buffer = rtc::scoped_refptr<webrtc::I420Buffer> buffer =
mBufferPool.CreateI420Buffer(aFrame.mSize.width, aFrame.mSize.height); mBufferPool.CreateI420Buffer(aFrame.mSize.width, aFrame.mSize.height);
if (!buffer) { if (!buffer) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH(
"Buffers not leaving scope except for " "Buffers not leaving scope except for "
"reconfig, should never leak"); "reconfig, should never leak");
LOG(LogLevel::Warning, LOG(LogLevel::Warning,
"VideoFrameConverterImpl %p: Creating a buffer for a black video " "VideoFrameConverterImpl %p: Creating a buffer for a black video "
"frame failed", "frame failed",

View File

@ -299,7 +299,7 @@ void HLSDecoder::UpdateCurrentPrincipal(nsIURI* aMediaUri) {
// Principals are disjoint -- no access. // Principals are disjoint -- no access.
mContentPrincipal = NullPrincipal::Create(OriginAttributes()); mContentPrincipal = NullPrincipal::Create(OriginAttributes());
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "non-equal principals should be disjoint"); MOZ_DIAGNOSTIC_CRASH("non-equal principals should be disjoint");
mContentPrincipal = nullptr; mContentPrincipal = nullptr;
} }
MediaDecoder::NotifyPrincipalChanged(); MediaDecoder::NotifyPrincipalChanged();

View File

@ -653,7 +653,7 @@ void RespondWithHandler::ResolvedCallback(JSContext* aCx,
if (NS_WARN_IF((response->Type() == ResponseType::Opaque || if (NS_WARN_IF((response->Type() == ResponseType::Opaque ||
response->Type() == ResponseType::Cors) && response->Type() == ResponseType::Cors) &&
ir->GetUnfilteredURL().IsEmpty())) { ir->GetUnfilteredURL().IsEmpty())) {
MOZ_DIAGNOSTIC_ASSERT(false, "Cors or opaque Response without a URL"); MOZ_DIAGNOSTIC_CRASH("Cors or opaque Response without a URL");
return; return;
} }

View File

@ -1542,7 +1542,7 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx,
if (NS_WARN_IF((response->Type() == ResponseType::Opaque || if (NS_WARN_IF((response->Type() == ResponseType::Opaque ||
response->Type() == ResponseType::Cors) && response->Type() == ResponseType::Cors) &&
ir->GetUnfilteredURL().IsEmpty())) { ir->GetUnfilteredURL().IsEmpty())) {
MOZ_DIAGNOSTIC_ASSERT(false, "Cors or opaque Response without a URL"); MOZ_DIAGNOSTIC_CRASH("Cors or opaque Response without a URL");
return; return;
} }

View File

@ -1031,9 +1031,9 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader,
// Make non-release and debug builds to crash if this happens and fail // Make non-release and debug builds to crash if this happens and fail
// explicitly on release builds. // explicitly on release builds.
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH(
"ServiceWorker imported script redirected to an url " "ServiceWorker imported script redirected to an url "
"with an unexpected scheme"); "with an unexpected scheme");
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -49,7 +49,7 @@ nsresult nsXMLPrettyPrinter::PrettyPrint(Document* aDocument,
// nsXMLContentSink should not ask us to pretty print an XML doc that comes // nsXMLContentSink should not ask us to pretty print an XML doc that comes
// with a CanAttachShadowDOM() == true root element, but just in case: // with a CanAttachShadowDOM() == true root element, but just in case:
if (rootElement->CanAttachShadowDOM()) { if (rootElement->CanAttachShadowDOM()) {
MOZ_DIAGNOSTIC_ASSERT(false, "We shouldn't be getting this root element"); MOZ_DIAGNOSTIC_CRASH("We shouldn't be getting this root element");
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -37,10 +37,10 @@ static inline SkColorType GfxFormatToSkiaColorType(SurfaceFormat format) {
case SurfaceFormat::R8G8B8A8: case SurfaceFormat::R8G8B8A8:
return kRGBA_8888_SkColorType; return kRGBA_8888_SkColorType;
case SurfaceFormat::A8R8G8B8: case SurfaceFormat::A8R8G8B8:
MOZ_DIAGNOSTIC_ASSERT(false, "A8R8G8B8 unsupported by Skia"); MOZ_DIAGNOSTIC_CRASH("A8R8G8B8 unsupported by Skia");
return kRGBA_8888_SkColorType; return kRGBA_8888_SkColorType;
default: default:
MOZ_DIAGNOSTIC_ASSERT(false, "Unknown surface format"); MOZ_DIAGNOSTIC_CRASH("Unknown surface format");
return kRGBA_8888_SkColorType; return kRGBA_8888_SkColorType;
} }
} }

View File

@ -277,8 +277,7 @@ CanvasRenderThread::CreateWorkerTaskQueue() {
/* static */ void CanvasRenderThread::Dispatch( /* static */ void CanvasRenderThread::Dispatch(
already_AddRefed<nsIRunnable> aRunnable) { already_AddRefed<nsIRunnable> aRunnable) {
if (!sCanvasRenderThread) { if (!sCanvasRenderThread) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("Dispatching after CanvasRenderThread shutdown!");
"Dispatching after CanvasRenderThread shutdown!");
return; return;
} }
sCanvasRenderThread->mThread->Dispatch(std::move(aRunnable)); sCanvasRenderThread->mThread->Dispatch(std::move(aRunnable));

View File

@ -279,7 +279,7 @@ bool CanvasTranslator::AddBuffer(ipc::SharedMemory::Handle&& aBufferHandle,
gfxCriticalNote << "CanvasTranslator::AddBuffer bad state " gfxCriticalNote << "CanvasTranslator::AddBuffer bad state "
<< uint32_t(State(mHeader->readerState)); << uint32_t(State(mHeader->readerState));
#ifndef FUZZING_SNAPSHOT #ifndef FUZZING_SNAPSHOT
MOZ_DIAGNOSTIC_ASSERT(false, "mHeader->readerState == State::Paused"); MOZ_DIAGNOSTIC_CRASH("mHeader->readerState == State::Paused");
#endif #endif
Deactivate(); Deactivate();
return false; return false;
@ -343,7 +343,7 @@ bool CanvasTranslator::SetDataSurfaceBuffer(
gfxCriticalNote << "CanvasTranslator::SetDataSurfaceBuffer bad state " gfxCriticalNote << "CanvasTranslator::SetDataSurfaceBuffer bad state "
<< uint32_t(State(mHeader->readerState)); << uint32_t(State(mHeader->readerState));
#ifndef FUZZING_SNAPSHOT #ifndef FUZZING_SNAPSHOT
MOZ_DIAGNOSTIC_ASSERT(false, "mHeader->readerState == State::Paused"); MOZ_DIAGNOSTIC_CRASH("mHeader->readerState == State::Paused");
#endif #endif
Deactivate(); Deactivate();
return false; return false;
@ -1152,7 +1152,7 @@ already_AddRefed<gfx::DrawTarget> CanvasTranslator::CreateDrawTarget(
const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) { const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) {
if (!aTextureOwnerId.IsValid()) { if (!aTextureOwnerId.IsValid()) {
#ifndef FUZZING_SNAPSHOT #ifndef FUZZING_SNAPSHOT
MOZ_DIAGNOSTIC_ASSERT(false, "No texture owner set"); MOZ_DIAGNOSTIC_CRASH("No texture owner set");
#endif #endif
return nullptr; return nullptr;
} }
@ -1191,7 +1191,7 @@ already_AddRefed<gfx::DrawTarget> CanvasTranslator::CreateDrawTarget(
gfx::ReferencePtr aRefPtr, const gfx::IntSize& aSize, gfx::ReferencePtr aRefPtr, const gfx::IntSize& aSize,
gfx::SurfaceFormat aFormat) { gfx::SurfaceFormat aFormat) {
#ifndef FUZZING_SNAPSHOT #ifndef FUZZING_SNAPSHOT
MOZ_DIAGNOSTIC_ASSERT(false, "Unexpected CreateDrawTarget call!"); MOZ_DIAGNOSTIC_CRASH("Unexpected CreateDrawTarget call!");
#endif #endif
return nullptr; return nullptr;
} }

View File

@ -62,7 +62,7 @@ void CompositorManagerChild::InitSameProcess(uint32_t aNamespace,
aProcessToken, aNamespace, /* aSameProcess */ true); aProcessToken, aNamespace, /* aSameProcess */ true);
child->SetOtherEndpointProcInfo(ipc::EndpointProcInfo::Current()); child->SetOtherEndpointProcInfo(ipc::EndpointProcInfo::Current());
if (NS_WARN_IF(!child->Open(parent, CompositorThread(), ipc::ChildSide))) { if (NS_WARN_IF(!child->Open(parent, CompositorThread(), ipc::ChildSide))) {
MOZ_DIAGNOSTIC_ASSERT(false, "Failed to open same process protocol"); MOZ_DIAGNOSTIC_CRASH("Failed to open same process protocol");
return; return;
} }
child->mCanSend = true; child->mCanSend = true;

View File

@ -261,7 +261,7 @@ Result<Ok, LaunchError> LaunchApp(const std::wstring& cmdline,
for (HANDLE h : options.handles_to_inherit) { for (HANDLE h : options.handles_to_inherit) {
if (SetHandleInformation(h, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) == if (SetHandleInformation(h, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) ==
0) { 0) {
MOZ_DIAGNOSTIC_ASSERT(false, "SetHandleInformation failed"); MOZ_DIAGNOSTIC_CRASH("SetHandleInformation failed");
return Err( return Err(
LaunchError::FromWin32Error("SetHandleInformation", GetLastError())); LaunchError::FromWin32Error("SetHandleInformation", GetLastError()));
} }

View File

@ -538,7 +538,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
if (msg->attached_handles_.Length() > if (msg->attached_handles_.Length() >
IPC::Message::MAX_DESCRIPTORS_PER_MESSAGE) { IPC::Message::MAX_DESCRIPTORS_PER_MESSAGE) {
MOZ_DIAGNOSTIC_ASSERT(false, "Too many file descriptors!"); MOZ_DIAGNOSTIC_CRASH("Too many file descriptors!");
CHROMIUM_LOG(FATAL) << "Too many file descriptors!"; CHROMIUM_LOG(FATAL) << "Too many file descriptors!";
// This should not be reached. // This should not be reached.
return false; return false;
@ -560,7 +560,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
} }
if (partial_write_->iter_.Done()) { if (partial_write_->iter_.Done()) {
MOZ_DIAGNOSTIC_ASSERT(false, "partial_write_->iter_ should not be done"); MOZ_DIAGNOSTIC_CRASH("partial_write_->iter_ should not be done");
// report a send error to our caller, which will close the channel. // report a send error to our caller, which will close the channel.
return false; return false;
} }

View File

@ -1888,7 +1888,7 @@ ArrayBufferObject::createUninitializedBufferAndData(
if (!data) { if (!data) {
if (cx->brittleMode) { if (cx->brittleMode) {
if (nbytes < INT32_MAX) { if (nbytes < INT32_MAX) {
MOZ_DIAGNOSTIC_ASSERT(false, "ArrayBuffer allocation OOM < 2GB - 1"); MOZ_DIAGNOSTIC_CRASH("ArrayBuffer allocation OOM < 2GB - 1");
} else { } else {
MOZ_DIAGNOSTIC_ASSERT( MOZ_DIAGNOSTIC_ASSERT(
false, false,

View File

@ -338,7 +338,7 @@ Result<Ok, nsresult> URLPreloader::ReadCache(
"Entry should be in pendingURLs"); "Entry should be in pendingURLs");
MOZ_DIAGNOSTIC_ASSERT(key.mPath.Length() > 0, MOZ_DIAGNOSTIC_ASSERT(key.mPath.Length() > 0,
"Path should be non-empty"); "Path should be non-empty");
MOZ_DIAGNOSTIC_ASSERT(false, "Entry should be new and not in any list"); MOZ_DIAGNOSTIC_CRASH("Entry should be new and not in any list");
#endif #endif
return Err(NS_ERROR_UNEXPECTED); return Err(NS_ERROR_UNEXPECTED);
} }

View File

@ -144,7 +144,7 @@ static FrameChildListID ChildListIDForOutOfFlow(nsFrameState aPlaceholderState,
if (aPlaceholderState & PLACEHOLDER_FOR_ABSPOS) { if (aPlaceholderState & PLACEHOLDER_FOR_ABSPOS) {
return FrameChildListID::Absolute; return FrameChildListID::Absolute;
} }
MOZ_DIAGNOSTIC_ASSERT(false, "unknown list"); MOZ_DIAGNOSTIC_CRASH("unknown list");
return FrameChildListID::Float; return FrameChildListID::Float;
} }

View File

@ -137,7 +137,7 @@ void AssertUniqueItem(nsDisplayItem* aItem) {
if (i->IsPreProcessedItem() || i->IsPreProcessed()) { if (i->IsPreProcessedItem() || i->IsPreProcessed()) {
continue; continue;
} }
MOZ_DIAGNOSTIC_ASSERT(false, "Duplicate display item!"); MOZ_DIAGNOSTIC_CRASH("Duplicate display item!");
} }
} }
} }

View File

@ -2229,7 +2229,7 @@ void LoadInfo::SetReservedClientInfo(const ClientInfo& aClientInfo) {
if (mReservedClientInfo.ref() == aClientInfo) { if (mReservedClientInfo.ref() == aClientInfo) {
return; return;
} }
MOZ_DIAGNOSTIC_ASSERT(false, "mReservedClientInfo already set"); MOZ_DIAGNOSTIC_CRASH("mReservedClientInfo already set");
mReservedClientInfo.reset(); mReservedClientInfo.reset();
} }
mReservedClientInfo.emplace(aClientInfo); mReservedClientInfo.emplace(aClientInfo);

View File

@ -19,7 +19,7 @@ void HostRecordQueue::InsertRecord(nsHostRecord* aRec,
MOZ_DIAGNOSTIC_ASSERT(!mHighQ.contains(aRec), "Already in high queue"); MOZ_DIAGNOSTIC_ASSERT(!mHighQ.contains(aRec), "Already in high queue");
MOZ_DIAGNOSTIC_ASSERT(!mMediumQ.contains(aRec), "Already in med queue"); MOZ_DIAGNOSTIC_ASSERT(!mMediumQ.contains(aRec), "Already in med queue");
MOZ_DIAGNOSTIC_ASSERT(!mLowQ.contains(aRec), "Already in low queue"); MOZ_DIAGNOSTIC_ASSERT(!mLowQ.contains(aRec), "Already in low queue");
MOZ_DIAGNOSTIC_ASSERT(false, "Already on some other queue?"); MOZ_DIAGNOSTIC_CRASH("Already on some other queue?");
} }
switch (AddrHostRecord::GetPriority(aFlags)) { switch (AddrHostRecord::GetPriority(aFlags)) {
@ -51,7 +51,7 @@ void HostRecordQueue::AddToEvictionQ(
MOZ_DIAGNOSTIC_ASSERT(!inMediumQ, "Already in med queue"); MOZ_DIAGNOSTIC_ASSERT(!inMediumQ, "Already in med queue");
bool inLowQ = mLowQ.contains(aRec); bool inLowQ = mLowQ.contains(aRec);
MOZ_DIAGNOSTIC_ASSERT(!inLowQ, "Already in low queue"); MOZ_DIAGNOSTIC_ASSERT(!inLowQ, "Already in low queue");
MOZ_DIAGNOSTIC_ASSERT(false, "Already on some other queue?"); MOZ_DIAGNOSTIC_CRASH("Already on some other queue?");
// Bug 1678117 - it's not clear why this can happen, but let's fix it // Bug 1678117 - it's not clear why this can happen, but let's fix it
// for release users. // for release users.

View File

@ -233,7 +233,7 @@ AHostResolver::LookupStatus TRRQuery::CompleteLookup(
mTRRRequestCounter--; mTRRRequestCounter--;
pendingRequest = (mTRRRequestCounter != 0); pendingRequest = (mTRRRequestCounter != 0);
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, "Request counter is messed up"); MOZ_DIAGNOSTIC_CRASH("Request counter is messed up");
} }
if (pendingRequest) { // There are other outstanding requests if (pendingRequest) { // There are other outstanding requests
LOG(("CompleteLookup: waiting for all responses!\n")); LOG(("CompleteLookup: waiting for all responses!\n"));

View File

@ -329,7 +329,7 @@ nsresult nsHttpHandler::Init() {
// xpcshell tests doing this. // xpcshell tests doing this.
if (MOZ_UNLIKELY(AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdown) && if (MOZ_UNLIKELY(AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdown) &&
!PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR"))) { !PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR"))) {
MOZ_DIAGNOSTIC_ASSERT(false, "Try to init HttpHandler after shutdown"); MOZ_DIAGNOSTIC_CRASH("Try to init HttpHandler after shutdown");
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
} }

View File

@ -773,7 +773,7 @@ nsresult nsNetworkLinkService::Init(void) {
if (inet_pton(AF_INET, ROUTE_CHECK_IPV4, &mRouteCheckIPv4) != 1) { if (inet_pton(AF_INET, ROUTE_CHECK_IPV4, &mRouteCheckIPv4) != 1) {
LOG(("Cannot parse address " ROUTE_CHECK_IPV4)); LOG(("Cannot parse address " ROUTE_CHECK_IPV4));
MOZ_DIAGNOSTIC_ASSERT(false, "Cannot parse address " ROUTE_CHECK_IPV4); MOZ_DIAGNOSTIC_CRASH("Cannot parse address " ROUTE_CHECK_IPV4);
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -1238,13 +1238,13 @@ nsresult NetlinkService::Init(NetlinkServiceListener* aListener) {
if (inet_pton(AF_INET, ROUTE_CHECK_IPV4, &mRouteCheckIPv4) != 1) { if (inet_pton(AF_INET, ROUTE_CHECK_IPV4, &mRouteCheckIPv4) != 1) {
LOG(("Cannot parse address " ROUTE_CHECK_IPV4)); LOG(("Cannot parse address " ROUTE_CHECK_IPV4));
MOZ_DIAGNOSTIC_ASSERT(false, "Cannot parse address " ROUTE_CHECK_IPV4); MOZ_DIAGNOSTIC_CRASH("Cannot parse address " ROUTE_CHECK_IPV4);
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
if (inet_pton(AF_INET6, ROUTE_CHECK_IPV6, &mRouteCheckIPv6) != 1) { if (inet_pton(AF_INET6, ROUTE_CHECK_IPV6, &mRouteCheckIPv6) != 1) {
LOG(("Cannot parse address " ROUTE_CHECK_IPV6)); LOG(("Cannot parse address " ROUTE_CHECK_IPV6));
MOZ_DIAGNOSTIC_ASSERT(false, "Cannot parse address " ROUTE_CHECK_IPV6); MOZ_DIAGNOSTIC_CRASH("Cannot parse address " ROUTE_CHECK_IPV6);
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -107,7 +107,7 @@ int variantToSQLiteT(T aObj, nsIVariant* aValue) {
return sqlite3_T_array(aObj, data, count, CARRAY_TEXT); return sqlite3_T_array(aObj, data, count, CARRAY_TEXT);
} }
MOZ_DIAGNOSTIC_ASSERT(false, "Unsupported type in Storage bound array"); MOZ_DIAGNOSTIC_CRASH("Unsupported type in Storage bound array");
// Technically this could leak with certain data types, but somebody was // Technically this could leak with certain data types, but somebody was
// being incautious passing us this anyway. // being incautious passing us this anyway.
free(data); free(data);

View File

@ -79,7 +79,7 @@ class ExtensionAPIRequest : public mozIExtensionAPIRequest {
case APIRequestType::REMOVE_LISTENER: case APIRequestType::REMOVE_LISTENER:
break; break;
default: default:
MOZ_DIAGNOSTIC_ASSERT(false, "Unexpected APIRequestType"); MOZ_DIAGNOSTIC_CRASH("Unexpected APIRequestType");
} }
return false; return false;

View File

@ -515,7 +515,7 @@ bool RequestWorkerRunnable::HandleAPIRequest(
if (isExtensionError && !okSerializedError) { if (isExtensionError && !okSerializedError) {
NS_WARNING("Failed to wrap ClonedErrorHolder"); NS_WARNING("Failed to wrap ClonedErrorHolder");
MOZ_DIAGNOSTIC_ASSERT(false, "Failed to wrap ClonedErrorHolder"); MOZ_DIAGNOSTIC_CRASH("Failed to wrap ClonedErrorHolder");
return false; return false;
} }
@ -534,7 +534,7 @@ bool RequestWorkerRunnable::HandleAPIRequest(
return ProcessHandlerResult(aCx, aRetval); return ProcessHandlerResult(aCx, aRetval);
} }
MOZ_DIAGNOSTIC_ASSERT(false, "Unexpected API request ResultType"); MOZ_DIAGNOSTIC_CRASH("Unexpected API request ResultType");
return false; return false;
} }
@ -590,7 +590,7 @@ bool RequestWorkerRunnable::ProcessHandlerResult(
} }
} }
MOZ_DIAGNOSTIC_ASSERT(false, "Unexpected API request ResultType"); MOZ_DIAGNOSTIC_CRASH("Unexpected API request ResultType");
return false; return false;
} }
@ -627,7 +627,7 @@ void RequestWorkerRunnable::ReadResult(JSContext* aCx,
return; return;
} }
MOZ_DIAGNOSTIC_ASSERT(false, "Unexpected API request ResultType"); MOZ_DIAGNOSTIC_CRASH("Unexpected API request ResultType");
aRv.Throw(NS_ERROR_UNEXPECTED); aRv.Throw(NS_ERROR_UNEXPECTED);
} }

View File

@ -1395,7 +1395,7 @@ void IPCFuzzController::SynchronizeOnMessageExecution(
MOZ_FUZZING_NYX_PRINT( MOZ_FUZZING_NYX_PRINT(
"ERROR: ======== END OF ITERATION (TIMEOUT) ========\n"); "ERROR: ======== END OF ITERATION (TIMEOUT) ========\n");
if (!!getenv("MOZ_FUZZ_CRASH_ON_TIMEOUT")) { if (!!getenv("MOZ_FUZZ_CRASH_ON_TIMEOUT")) {
MOZ_DIAGNOSTIC_ASSERT(false, "IPCFuzzController Timeout"); MOZ_DIAGNOSTIC_CRASH("IPCFuzzController Timeout");
} }
Nyx::instance().release( Nyx::instance().release(
IPCFuzzController::instance().getMessageStopCount()); IPCFuzzController::instance().getMessageStopCount());

View File

@ -108,7 +108,7 @@ void ContentCache::AssertIfInvalid() const {
? "Nothing" ? "Nothing"
: nsPrintfCString("%u", mCompositionStart.value()).get()); : nsPrintfCString("%u", mCompositionStart.value()).get());
CrashReporter::AppendAppNotesToCrashReport(info); CrashReporter::AppendAppNotesToCrashReport(info);
MOZ_DIAGNOSTIC_ASSERT(false, "Invalid ContentCache data"); MOZ_DIAGNOSTIC_CRASH("Invalid ContentCache data");
#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED #endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED
} }

View File

@ -810,7 +810,7 @@ nsresult WakeLockTopic::ProcessNextRequest() {
mState = WaitingToUninhibit; mState = WaitingToUninhibit;
return SendUninhibit() ? NS_OK : NS_ERROR_FAILURE; return SendUninhibit() ? NS_OK : NS_ERROR_FAILURE;
default: default:
MOZ_DIAGNOSTIC_ASSERT(false, "Wrong state!"); MOZ_DIAGNOSTIC_CRASH("Wrong state!");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
} }

View File

@ -538,7 +538,7 @@ void nsBaseClipboard::MaybeRetryGetAvailableFlavors(
return; return;
} }
MOZ_DIAGNOSTIC_ASSERT(false, "How can this happen?!?"); MOZ_DIAGNOSTIC_CRASH("How can this happen?!?");
callback->OnError(NS_ERROR_FAILURE); callback->OnError(NS_ERROR_FAILURE);
}); });
} }

View File

@ -958,7 +958,7 @@ nsresult nsPrintSettingsService::MaybeSavePrintSettingsToPrefs(
// defaults and can result in values being inappropriately propagated to // defaults and can result in values being inappropriately propagated to
// prefixed prefs). // prefixed prefs).
if (prtName.IsEmpty()) { if (prtName.IsEmpty()) {
MOZ_DIAGNOSTIC_ASSERT(false, "Print settings must be saved with a prefix"); MOZ_DIAGNOSTIC_CRASH("Print settings must be saved with a prefix");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
#endif #endif

View File

@ -4807,8 +4807,7 @@ bool nsWindow::ProcessMessageInternal(UINT msg, WPARAM& wParam, LPARAM& lParam,
} else if (lParam & (ENDSESSION_CLOSEAPP | ENDSESSION_CRITICAL)) { } else if (lParam & (ENDSESSION_CLOSEAPP | ENDSESSION_CRITICAL)) {
shutdownReason = AppShutdownReason::OSForceClose; shutdownReason = AppShutdownReason::OSForceClose;
} else { } else {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("Received WM_ENDSESSION with unknown flags.");
"Received WM_ENDSESSION with unknown flags.");
shutdownReason = AppShutdownReason::OSForceClose; shutdownReason = AppShutdownReason::OSForceClose;
} }

View File

@ -146,13 +146,12 @@ class ExpirationTrackerImpl {
*/ */
nsresult AddObjectLocked(T* aObj, const AutoLock& aAutoLock) { nsresult AddObjectLocked(T* aObj, const AutoLock& aAutoLock) {
if (NS_WARN_IF(!aObj)) { if (NS_WARN_IF(!aObj)) {
MOZ_DIAGNOSTIC_ASSERT(false, "Invalid object to add"); MOZ_DIAGNOSTIC_CRASH("Invalid object to add");
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
nsExpirationState* state = aObj->GetExpirationState(); nsExpirationState* state = aObj->GetExpirationState();
if (NS_WARN_IF(state->IsTracked())) { if (NS_WARN_IF(state->IsTracked())) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("Tried to add an object that's already tracked");
"Tried to add an object that's already tracked");
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
nsTArray<T*>& generation = mGenerations[mNewestGeneration]; nsTArray<T*>& generation = mGenerations[mNewestGeneration];
@ -181,13 +180,12 @@ class ExpirationTrackerImpl {
*/ */
void RemoveObjectLocked(T* aObj, const AutoLock& aAutoLock) { void RemoveObjectLocked(T* aObj, const AutoLock& aAutoLock) {
if (NS_WARN_IF(!aObj)) { if (NS_WARN_IF(!aObj)) {
MOZ_DIAGNOSTIC_ASSERT(false, "Invalid object to remove"); MOZ_DIAGNOSTIC_CRASH("Invalid object to remove");
return; return;
} }
nsExpirationState* state = aObj->GetExpirationState(); nsExpirationState* state = aObj->GetExpirationState();
if (NS_WARN_IF(!state->IsTracked())) { if (NS_WARN_IF(!state->IsTracked())) {
MOZ_DIAGNOSTIC_ASSERT(false, MOZ_DIAGNOSTIC_CRASH("Tried to remove an object that's not tracked");
"Tried to remove an object that's not tracked");
return; return;
} }
nsTArray<T*>& generation = mGenerations[state->mGeneration]; nsTArray<T*>& generation = mGenerations[state->mGeneration];