tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit eae555791f606b6987b8654b0ce287ef2eebc2d7
parent df083c2c45d1e7e81624a19cac3bf30cc7504c80
Author: Serban Stanca <sstanca@mozilla.com>
Date:   Wed,  1 Oct 2025 01:10:14 +0300

Revert "Bug 1991395 - Better encapsulation for chaos mode r=necko-reviewers,kershaw" for causing build bustages.

This reverts commit 5644eaf736fa90ab53d1a25c79812099ded74d3e.

Diffstat:
Amfbt/ChaosMode.cpp | 17+++++++++++++++++
Mmfbt/ChaosMode.h | 25++++++++++++++-----------
Mmfbt/moz.build | 1+
Mnetwerk/protocol/http/ConnectionEntry.cpp | 1+
4 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/mfbt/ChaosMode.cpp b/mfbt/ChaosMode.cpp @@ -0,0 +1,17 @@ +/* -*- 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/. */ + +#include "mozilla/ChaosMode.h" + +namespace mozilla { + +namespace detail { + +Atomic<uint32_t, Relaxed> gChaosModeCounter(0); +ChaosFeature gChaosFeatures = ChaosFeature::Any; + +} /* namespace detail */ +} /* namespace mozilla */ diff --git a/mfbt/ChaosMode.h b/mfbt/ChaosMode.h @@ -7,10 +7,11 @@ #ifndef mozilla_ChaosMode_h #define mozilla_ChaosMode_h -#include "mozilla/Assertions.h" #include "mozilla/Atomics.h" +#include "mozilla/EnumSet.h" -#include <cstdint> +#include <stdint.h> +#include <stdlib.h> namespace mozilla { @@ -35,23 +36,25 @@ enum class ChaosFeature : uint32_t { Any = 0xffffffff, }; +namespace detail { +extern MFBT_DATA Atomic<uint32_t, Relaxed> gChaosModeCounter; +extern MFBT_DATA ChaosFeature gChaosFeatures; +} // namespace detail + /** * When "chaos mode" is activated, code that makes implicitly nondeterministic * choices is encouraged to make random and extreme choices, to test more * code paths and uncover bugs. */ class ChaosMode { - static inline MFBT_DATA Atomic<uint32_t, Relaxed> ChaosModeCounter{0}; - static inline MFBT_DATA ChaosFeature ChaosFeatures = ChaosFeature::Any; - public: static void SetChaosFeature(ChaosFeature aChaosFeature) { - ChaosFeatures = aChaosFeature; + detail::gChaosFeatures = aChaosFeature; } static bool isActive(ChaosFeature aFeature) { - return ChaosModeCounter > 0 && - (uint32_t(ChaosFeatures) & uint32_t(aFeature)); + return detail::gChaosModeCounter > 0 && + (uint32_t(detail::gChaosFeatures) & uint32_t(aFeature)); } /** @@ -59,14 +62,14 @@ class ChaosMode { * calls to leaveChaosMode must be made in order to restore the original * chaos mode state. */ - static void enterChaosMode() { ChaosModeCounter++; } + static void enterChaosMode() { detail::gChaosModeCounter++; } /** * Decrease the chaos mode activation level. See enterChaosMode(). */ static void leaveChaosMode() { - MOZ_ASSERT(ChaosModeCounter > 0); - ChaosModeCounter--; + MOZ_ASSERT(detail::gChaosModeCounter > 0); + detail::gChaosModeCounter--; } /** diff --git a/mfbt/moz.build b/mfbt/moz.build @@ -155,6 +155,7 @@ if CONFIG["OS_ARCH"] == "WASI": UNIFIED_SOURCES += [ "Assertions.cpp", + "ChaosMode.cpp", "double-conversion/double-conversion/bignum-dtoa.cc", "double-conversion/double-conversion/bignum.cc", "double-conversion/double-conversion/cached-powers.cc", diff --git a/netwerk/protocol/http/ConnectionEntry.cpp b/netwerk/protocol/http/ConnectionEntry.cpp @@ -15,6 +15,7 @@ #include "ConnectionEntry.h" #include "HttpConnectionUDP.h" #include "nsQueryObject.h" +#include "mozilla/ChaosMode.h" #include "mozilla/StaticPrefs_network.h" #include "nsHttpHandler.h" #include "mozilla/net/neqo_glue_ffi_generated.h"