Unreviewed, rolling out r241620.
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Feb 2019 00:11:24 +0000 (00:11 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Feb 2019 00:11:24 +0000 (00:11 +0000)
"Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
(Requested by ddkilzer on #webkit.)

Reverted changeset:

"[WTF] Add environment variable helpers"
https://bugs.webkit.org/show_bug.cgi?id=192405
https://trac.webkit.org/changeset/241620# Please enter the commit message for your changes. Lines starting

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241654 268f45cc-cd09-0410-ab3c-d52691b4dbfc

84 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/Options.cpp
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/tools/CodeProfiling.cpp
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/DataLog.cpp
Source/WTF/wtf/Environment.h [deleted file]
Source/WTF/wtf/NumberOfCores.cpp
Source/WTF/wtf/PlatformGTK.cmake
Source/WTF/wtf/PlatformJSCOnly.cmake
Source/WTF/wtf/PlatformMac.cmake
Source/WTF/wtf/PlatformPlayStation.cmake
Source/WTF/wtf/PlatformWPE.cmake
Source/WTF/wtf/PlatformWin.cmake
Source/WTF/wtf/Threading.cpp
Source/WTF/wtf/Threading.h
Source/WTF/wtf/posix/EnvironmentPOSIX.cpp [deleted file]
Source/WTF/wtf/posix/FileSystemPOSIX.cpp
Source/WTF/wtf/win/EnvironmentWin.cpp [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/unix/LoggingUnix.cpp
Source/WebCore/PAL/pal/win/LoggingWin.cpp
Source/WebCore/platform/NotImplemented.h
Source/WebCore/platform/cocoa/SystemVersion.mm
Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngine.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp
Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp
Source/WebCore/platform/gtk/RenderThemeWidget.cpp
Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
Source/WebCore/platform/network/curl/CurlContext.cpp
Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp
Source/WebCore/platform/network/playstation/CurlSSLHandlePlayStation.cpp
Source/WebCore/platform/network/win/CurlSSLHandleWin.cpp
Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
Source/WebCore/platform/unix/LoggingUnix.cpp
Source/WebCore/platform/win/LoggingWin.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp
Source/WebKit/Platform/unix/LoggingUnix.cpp
Source/WebKit/Platform/win/LoggingWin.cpp
Source/WebKit/PluginProcess/mac/PluginProcessMac.mm
Source/WebKit/Shared/Plugins/unix/PluginSearchPath.cpp
Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp
Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp
Source/WebKit/UIProcess/API/wpe/WPEView.cpp
Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp
Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp
Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp
Source/WebKit/WebProcess/EntryPoint/unix/WebProcessMain.cpp
Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp
Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/Misc/WebUIKitSupport.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp
Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp
Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp
Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestBus.cpp
Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp
Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleGtk.cpp
Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleUtilities.cpp
Tools/WebKitTestRunner/InjectedBundle/wpe/ActivateFontsWPE.cpp
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Tools/WebKitTestRunner/gtk/main.cpp
Tools/WebKitTestRunner/mac/TestControllerMac.mm
Tools/WebKitTestRunner/wpe/main.cpp

index 165c182..169468f 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-17  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r241612.
index 629d2e9..c075698 100644 (file)
@@ -32,7 +32,6 @@
 #include "RemoteConnectionToTarget.h"
 #include "RemoteInspectionTarget.h"
 #include <gio/gio.h>
-#include <wtf/Environment.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RunLoop.h>
 #include <wtf/glib/GUniquePtr.h>
@@ -52,7 +51,7 @@ RemoteInspector& RemoteInspector::singleton()
 
 RemoteInspector::RemoteInspector()
 {
-    if (Environment::get("WEBKIT_INSPECTOR_SERVER"))
+    if (g_getenv("WEBKIT_INSPECTOR_SERVER"))
         start();
 }
 
@@ -66,7 +65,7 @@ void RemoteInspector::start()
     m_enabled = true;
     m_cancellable = adoptGRef(g_cancellable_new());
 
-    GUniquePtr<char> inspectorAddress(g_strdup(Environment::getRaw("WEBKIT_INSPECTOR_SERVER")));
+    GUniquePtr<char> inspectorAddress(g_strdup(g_getenv("WEBKIT_INSPECTOR_SERVER")));
     char* portPtr = g_strrstr(inspectorAddress.get(), ":");
     ASSERT(portPtr);
     *portPtr = '\0';
@@ -80,7 +79,7 @@ void RemoteInspector::start()
             if (GRefPtr<GDBusConnection> connection = adoptGRef(g_dbus_connection_new_for_address_finish(result, &error.outPtr())))
                 inspector->setupConnection(WTFMove(connection));
             else if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
-                g_warning("RemoteInspector failed to connect to inspector server at: %s: %s", Environment::getRaw("WEBKIT_INSPECTOR_SERVER"), error->message);
+                g_warning("RemoteInspector failed to connect to inspector server at: %s: %s", g_getenv("WEBKIT_INSPECTOR_SERVER"), error->message);
     }, this);
 }
 
index 2da8f91..be01806 100644 (file)
@@ -83,7 +83,6 @@
 #include <type_traits>
 #include <wtf/Box.h>
 #include <wtf/CommaPrinter.h>
-#include <wtf/Environment.h>
 #include <wtf/MainThread.h>
 #include <wtf/MemoryPressureHandler.h>
 #include <wtf/MonotonicTime.h>
@@ -2251,11 +2250,9 @@ static double s_timeoutMultiplier = 1.0;
 
 static void startTimeoutThreadIfNeeded()
 {
-    if (auto timeoutString = Environment::get("JSCTEST_timeout")) {
-        bool ok;
-        s_desiredTimeout = timeoutString->toDouble(&ok);
-        if (!ok) {
-            dataLog("WARNING: timeout string is malformed, got ", *timeoutString,
+    if (char* timeoutString = getenv("JSCTEST_timeout")) {
+        if (sscanf(timeoutString, "%lf", &s_desiredTimeout) != 1) {
+            dataLog("WARNING: timeout string is malformed, got ", timeoutString,
                 " but expected a number. Not using a timeout.\n");
         } else {
             Thread::create("jsc Timeout Thread", [] () {
index 84e8bb1..84d7326 100644 (file)
@@ -39,7 +39,6 @@
 #include <wtf/ASCIICType.h>
 #include <wtf/Compiler.h>
 #include <wtf/DataLog.h>
-#include <wtf/Environment.h>
 #include <wtf/NumberOfCores.h>
 #include <wtf/PointerPreparations.h>
 #include <wtf/StdLibExtras.h>
@@ -177,7 +176,7 @@ bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name,
     bool available = (availability == Options::Availability::Normal)
         || Options::isAvailable(id, availability);
 
-    const char* stringValue = Environment::getRaw(name);
+    const char* stringValue = getenv(name);
     if (!stringValue)
         return false;
     
@@ -190,11 +189,12 @@ bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name,
 
 bool Options::overrideAliasedOptionWithHeuristic(const char* name)
 {
-    const char* stringValue = Environment::getRaw(name);
+    const char* stringValue = getenv(name);
     if (!stringValue)
         return false;
 
-    auto aliasedOption = makeString(&name[4], "=", stringValue);
+    String aliasedOption;
+    aliasedOption = String(&name[4]) + "=" + stringValue;
     if (Options::setOption(aliasedOption.utf8().data()))
         return true;
 
@@ -597,9 +597,9 @@ void Options::initialize()
 
 #if ASAN_ENABLED && OS(LINUX) && ENABLE(WEBASSEMBLY_FAST_MEMORY)
             if (Options::useWebAssemblyFastMemory()) {
-                auto asanOptions = Environment::get("ASAN_OPTIONS");
+                const char* asanOptions = getenv("ASAN_OPTIONS");
                 bool okToUseWebAssemblyFastMemory = asanOptions
-                    && asanOptions->contains("allow_user_segv_handler=1") || asanOptions->contains("handle_segv=0");
+                    && (strstr(asanOptions, "allow_user_segv_handler=1") || strstr(asanOptions, "handle_segv=0"));
                 if (!okToUseWebAssemblyFastMemory) {
                     dataLogLn("WARNING: ASAN interferes with JSC signal handlers; useWebAssemblyFastMemory will be disabled.");
                     Options::useWebAssemblyFastMemory() = false;
index 0952ffe..102f98e 100644 (file)
 #include "WeakGCMapInlines.h"
 #include "WebAssemblyFunction.h"
 #include "WebAssemblyWrapperFunction.h"
-#include <wtf/Environment.h>
 #include <wtf/ProcessID.h>
 #include <wtf/ReadWriteLock.h>
 #include <wtf/SimpleStats.h>
@@ -198,7 +197,8 @@ static bool enableAssembler(ExecutableAllocator& executableAllocator)
         return false;
     }
 
-    return !Environment::hasValue("JavaScriptCoreUseJIT", "0");
+    char* canUseJITString = getenv("JavaScriptCoreUseJIT");
+    return !canUseJITString || atoi(canUseJITString);
 }
 #endif // ENABLE(!ASSEMBLER)
 
@@ -427,7 +427,8 @@ VM::VM(VMType vmType, HeapType heapType)
         m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this);
 
         StringPrintStream pathOut;
-        if (const char* profilerPath = Environment::getRaw("JSC_PROFILER_PATH"))
+        const char* profilerPath = getenv("JSC_PROFILER_PATH");
+        if (profilerPath)
             pathOut.print(profilerPath, "/");
         pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json");
         m_perBytecodeProfiler->registerToSaveAtExit(pathOut.toCString().data());
index f8ea799..94ebe8e 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "CodeProfile.h"
 #include "MachineContext.h"
-#include <wtf/Environment.h>
 #include <wtf/MetaAllocator.h>
 
 #if HAVE(SIGNAL_H)
@@ -86,19 +85,21 @@ void CodeProfiling::sample(void* pc, void** framePointer)
 void CodeProfiling::notifyAllocator(WTF::MetaAllocator* allocator)
 {
     // Check for JSC_CODE_PROFILING.
-    auto codeProfilingMode = Environment::getUInt("JSC_CODE_PROFILING");
+    const char* codeProfilingMode = getenv("JSC_CODE_PROFILING");
     if (!codeProfilingMode)
         return;
 
-    // Check for a valid mode, currently 1, 2, or 3.
+    // Check for a valid mode, currently "1", "2", or "3".
+    if (!codeProfilingMode[0] || codeProfilingMode[1])
+        return;
     switch (*codeProfilingMode) {
-    case 1:
+    case '1':
         s_mode = Enabled;
         break;
-    case 2:
+    case '2':
         s_mode = Verbose;
         break;
-    case 3:
+    case '3':
         s_mode = VeryVerbose;
         break;
     default:
index af99322..ad61a22 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-15  Ross Kirsling  <ross.kirsling@sony.com>
 
         [WTF] Add environment variable helpers
index 7e5ae22..e54641d 100644 (file)
@@ -89,7 +89,6 @@
                93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; };
                93F1993E19D7958D00C2390B /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1993D19D7958D00C2390B /* StringView.cpp */; };
                9BC70F05176C379D00101DEC /* AtomicStringTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC70F04176C379D00101DEC /* AtomicStringTable.cpp */; };
-               A307FD29220CB4350021B62C /* EnvironmentPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */; };
                A32D8FA521FFFAB400780662 /* ThreadingPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */; };
                A331D95B21F24992009F02AA /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95A21F24992009F02AA /* FileSystem.cpp */; };
                A331D95D21F249E4009F02AA /* FileSystemCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95C21F249E4009F02AA /* FileSystemCF.cpp */; };
                9BC70F04176C379D00101DEC /* AtomicStringTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomicStringTable.cpp; sourceTree = "<group>"; };
                9BD8F40A176C2AD80002D865 /* AtomicStringTable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtomicStringTable.h; sourceTree = "<group>"; };
                9C67C542589348E285B49699 /* IndexedContainerIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexedContainerIterator.h; sourceTree = "<group>"; };
-               A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnvironmentPOSIX.cpp; sourceTree = "<group>"; };
-               A307FD2A220CB4490021B62C /* Environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Environment.h; sourceTree = "<group>"; };
                A30D412C1F0DE0BA00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; };
                A30D412D1F0DE13F00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; };
                A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPOSIX.cpp; sourceTree = "<group>"; };
                A331D96321F24A2E009F02AA /* posix */ = {
                        isa = PBXGroup;
                        children = (
-                               A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */,
                                A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */,
                                A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */,
                                A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */,
                                FE05FAE61FDB214300093230 /* DumbPtrTraits.h */,
                                AD653DA82006B6C200D820D7 /* DumbValueTraits.h */,
                                1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */,
-                               A307FD2A220CB4490021B62C /* Environment.h */,
                                AD7C434A1DD2A4A70026888B /* Expected.h */,
                                A8A4729F151A825A004123FF /* ExportMacros.h */,
                                0F7C5FB51D885CF20044F5E2 /* FastBitVector.cpp */,
                                A8A472CE151A825B004123FF /* MetaAllocator.h */,
                                A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */,
                                FE7497ED209163060003565B /* MetaAllocatorPtr.h */,
+                               5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */,
+                               5FAD3AE021B9636600BEE178 /* URLHelpers.h */,
                                0F66B2821DC97BAB004A1D3F /* MonotonicTime.cpp */,
                                0F66B2831DC97BAB004A1D3F /* MonotonicTime.h */,
                                FE8225301B2A1E5B00BA68FD /* NakedPtr.h */,
                                5CC0EE7121629F1800A1A842 /* URL.h */,
                                5C1F0597216439940039302C /* URLHash.h */,
                                5CC0EE772162A01000A1A842 /* URLHash.h */,
-                               5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */,
-                               5FAD3AE021B9636600BEE178 /* URLHelpers.h */,
                                5CC0EE7321629F1900A1A842 /* URLParser.cpp */,
                                5CC0EE7221629F1900A1A842 /* URLParser.h */,
                                7AFEC6B01EB22B5900DADE36 /* UUID.cpp */,
                                A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
                                A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
                                143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */,
-                               A307FD29220CB4350021B62C /* EnvironmentPOSIX.cpp in Sources */,
                                50DE35F5215BB01500B979C7 /* ExternalStringImpl.cpp in Sources */,
                                A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
                                0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */,
                                5CC0EE8A2162BC2200A1A842 /* NSURLExtras.mm in Sources */,
                                A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */,
                                8348BA0E21FBC0D500FD3054 /* ObjectIdentifier.cpp in Sources */,
+                               5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */,
                                A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */,
                                A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */,
                                A8A47402151A825B004123FF /* PageBlock.cpp in Sources */,
                                5CC0EE7621629F1900A1A842 /* URL.cpp in Sources */,
                                5C1F0595216437B30039302C /* URLCF.cpp in Sources */,
                                5CC0EE892162BC2200A1A842 /* URLCocoa.mm in Sources */,
-                               5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */,
                                5CC0EE7521629F1900A1A842 /* URLParser.cpp in Sources */,
                                1C181C8F1D307AB800F5FA16 /* UTextProvider.cpp in Sources */,
                                1C181C911D307AB800F5FA16 /* UTextProviderLatin1.cpp in Sources */,
index 8104da3..1f12b79 100644 (file)
@@ -55,7 +55,6 @@ set(WTF_PUBLIC_HEADERS
     DumbPtrTraits.h
     DumbValueTraits.h
     EnumTraits.h
-    Environment.h
     Expected.h
     ExportMacros.h
     FastBitVector.h
index 3bcdd1a..57f9eb2 100644 (file)
 #include "config.h"
 #include <wtf/DataLog.h>
 
-#include <mutex>
 #include <stdarg.h>
 #include <string.h>
-#include <thread>
-#include <wtf/Environment.h>
 #include <wtf/FilePrintStream.h>
 #include <wtf/LockedPrintStream.h>
 #include <wtf/ProcessID.h>
 #include <wtf/Threading.h>
+#include <mutex>
+#include <thread>
 
 #if OS(UNIX) || OS(DARWIN)
 #include <unistd.h>
@@ -94,7 +93,7 @@ static void initializeLogFileOnce()
 #elif defined(DATA_LOG_FILENAME)
     filename = DATA_LOG_FILENAME;
 #else
-    filename = Environment::getRaw("WTF_DATA_LOG_FILENAME");
+    filename = getenv("WTF_DATA_LOG_FILENAME");
 #endif
     char actualFilename[maxPathLength + 1];
 
diff --git a/Source/WTF/wtf/Environment.h b/Source/WTF/wtf/Environment.h
deleted file mode 100644 (file)
index bb9e5be..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2019 Sony Interactive Entertainment Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/Optional.h>
-#include <wtf/text/WTFString.h>
-
-namespace WTF {
-namespace EnvironmentImpl {
-
-WTF_EXPORT_PRIVATE Optional<String> get(const String&);
-
-inline const char* getRaw(const String& variable)
-{
-    auto string = get(variable);
-    return string ? string->utf8().data() : nullptr;
-}
-
-inline Optional<int> getInt(const String& variable)
-{
-    auto string = get(variable);
-    if (!string)
-        return WTF::nullopt;
-
-    bool ok;
-    auto value = string->toIntStrict(&ok);
-    return ok ? makeOptional(value) : WTF::nullopt;
-}
-
-inline Optional<unsigned> getUInt(const String& variable)
-{
-    auto string = get(variable);
-    if (!string)
-        return WTF::nullopt;
-
-    bool ok;
-    auto value = string->toUIntStrict(&ok);
-    return ok ? makeOptional(value) : WTF::nullopt;
-}
-
-inline bool hasValue(const String& variable, const String& expected)
-{
-    auto actual = get(variable);
-    return actual && *actual == expected;
-}
-
-inline bool hasValueOtherThan(const String& variable, const String& expected)
-{
-    auto actual = get(variable);
-    return actual && *actual != expected;
-}
-
-WTF_EXPORT_PRIVATE void set(const String& variable, const String& value);
-WTF_EXPORT_PRIVATE void setIfNotDefined(const String& variable, const String& value);
-
-WTF_EXPORT_PRIVATE void remove(const String&);
-
-} // namespace EnvironmentImpl
-} // namespace WTF
-
-namespace Environment = WTF::EnvironmentImpl;
index 48a9cf2..62fa65a 100644 (file)
@@ -27,7 +27,6 @@
 #include <wtf/NumberOfCores.h>
 
 #include <cstdio>
-#include <wtf/Environment.h>
 
 #if OS(DARWIN)
 #include <sys/param.h>
@@ -50,16 +49,14 @@ int numberOfProcessorCores()
 
     if (s_numberOfCores > 0)
         return s_numberOfCores;
-
-    if (auto coresEnv = Environment::get("WTF_numberOfProcessorCores")) {
-        bool ok;
-        auto numberOfCores = coresEnv->toUIntStrict(&ok);
-        if (ok) {
+    
+    if (const char* coresEnv = getenv("WTF_numberOfProcessorCores")) {
+        unsigned numberOfCores;
+        if (sscanf(coresEnv, "%u", &numberOfCores) == 1) {
             s_numberOfCores = numberOfCores;
             return s_numberOfCores;
-        }
-
-        fprintf(stderr, "WARNING: failed to parse WTF_numberOfProcessorCores=%s\n", coresEnv->utf8().data());
+        } else
+            fprintf(stderr, "WARNING: failed to parse WTF_numberOfProcessorCores=%s\n", coresEnv);
     }
 
 #if OS(DARWIN)
index b55d0ec..297d0fa 100644 (file)
@@ -28,7 +28,6 @@ list(APPEND WTF_SOURCES
     glib/RunLoopGLib.cpp
     glib/URLGLib.cpp
 
-    posix/EnvironmentPOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
 
index 1932a7f..3542fef 100644 (file)
@@ -8,7 +8,6 @@ if (WIN32)
 
         win/CPUTimeWin.cpp
         win/DbgHelperWin.cpp
-        win/EnvironmentWin.cpp
         win/FileSystemWin.cpp
         win/LanguageWin.cpp
         win/MainThreadWin.cpp
@@ -34,7 +33,6 @@ else ()
 
         generic/MainThreadGeneric.cpp
 
-        posix/EnvironmentPOSIX.cpp
         posix/FileSystemPOSIX.cpp
         posix/OSAllocatorPOSIX.cpp
         posix/ThreadingPOSIX.cpp
index 339f2bb..9a1f510 100644 (file)
@@ -64,7 +64,6 @@ list(APPEND WTF_SOURCES
     mac/FileSystemMac.mm
     mac/SchedulePairMac.mm
 
-    posix/EnvironmentPOSIX.cpp
     posix/FileSystemPOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
index fc4a29f..4b69190 100644 (file)
@@ -5,7 +5,6 @@ list(APPEND WTF_SOURCES
     generic/RunLoopGeneric.cpp
     generic/WorkQueueGeneric.cpp
 
-    posix/EnvironmentPOSIX.cpp
     posix/FileSystemPOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
index eb5f739..38e632c 100644 (file)
@@ -26,7 +26,6 @@ list(APPEND WTF_SOURCES
     linux/MemoryFootprintLinux.cpp
     linux/MemoryPressureHandlerLinux.cpp
 
-    posix/EnvironmentPOSIX.cpp
     posix/OSAllocatorPOSIX.cpp
     posix/ThreadingPOSIX.cpp
 
index f65e121..2c34022 100644 (file)
@@ -12,7 +12,6 @@ list(APPEND WTF_SOURCES
 
     win/CPUTimeWin.cpp
     win/DbgHelperWin.cpp
-    win/EnvironmentWin.cpp
     win/FileSystemWin.cpp
     win/LanguageWin.cpp
     win/MainThreadWin.cpp
index a54575c..31e4ddc 100644 (file)
@@ -285,18 +285,10 @@ void Thread::dump(PrintStream& out) const
 ThreadSpecificKey Thread::s_key = InvalidThreadSpecificKey;
 #endif
 
-static bool initialized = false;
-
-bool threadingIsInitialized()
-{
-    return initialized;
-}
-
 void initializeThreading()
 {
     static std::once_flag onceKey;
     std::call_once(onceKey, [] {
-        initialized = true;
         initializeRandomNumberGenerator();
 #if !HAVE(FAST_TLS)
         Thread::initializeTLSKey();
index eee53ae..2d9242c 100644 (file)
@@ -61,8 +61,6 @@ enum class ThreadGroupAddResult;
 class ThreadGroup;
 class PrintStream;
 
-WTF_EXPORT_PRIVATE bool threadingIsInitialized();
-
 // This function can be called from any threads.
 WTF_EXPORT_PRIVATE void initializeThreading();
 
diff --git a/Source/WTF/wtf/posix/EnvironmentPOSIX.cpp b/Source/WTF/wtf/posix/EnvironmentPOSIX.cpp
deleted file mode 100644 (file)
index 35e7275..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2019 Sony Interactive Entertainment Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <wtf/Environment.h>
-
-#include <cstdlib>
-#include <wtf/Assertions.h>
-#include <wtf/Threading.h>
-
-namespace WTF {
-namespace EnvironmentImpl {
-
-Optional<String> get(const String& variable)
-{
-    auto value = getenv(variable.utf8().data());
-    return value ? makeOptional(String::fromUTF8(value)) : WTF::nullopt;
-}
-
-void set(const String& variable, const String& value)
-{
-    ASSERT(!WTF::threadingIsInitialized());
-    setenv(variable.utf8().data(), value.utf8().data(), 1);
-}
-
-void setIfNotDefined(const String& variable, const String& value)
-{
-    ASSERT(!WTF::threadingIsInitialized());
-    setenv(variable.utf8().data(), value.utf8().data(), 0);
-}
-
-void remove(const String& variable)
-{
-    ASSERT(!WTF::threadingIsInitialized());
-    unsetenv(variable.utf8().data());
-}
-
-} // namespace EnvironmentImpl
-} // namespace WTF
index dce9b37..70d2f98 100644 (file)
@@ -40,7 +40,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <wtf/EnumTraits.h>
-#include <wtf/Environment.h>
 #include <wtf/FileMetadata.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
@@ -425,8 +424,8 @@ bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace)
 String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
 {
     char buffer[PATH_MAX];
+    const char* tmpDir = getenv("TMPDIR");
 
-    const char* tmpDir = Environment::getRaw("TMPDIR");
     if (!tmpDir)
         tmpDir = "/tmp";
 
diff --git a/Source/WTF/wtf/win/EnvironmentWin.cpp b/Source/WTF/wtf/win/EnvironmentWin.cpp
deleted file mode 100644 (file)
index a36b966..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2019 Sony Interactive Entertainment Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <wtf/Environment.h>
-
-#include <windows.h>
-#include <wtf/Assertions.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
-
-namespace WTF {
-namespace EnvironmentImpl {
-
-Optional<String> get(const String& variable)
-{
-    auto rawVariable = variable.charactersWithNullTermination().data();
-    auto length = ::GetEnvironmentVariableW(rawVariable, nullptr, 0);
-    if (!length)
-        return WTF::nullopt;
-
-    Vector<UChar> buffer(length);
-    return ::GetEnvironmentVariableW(rawVariable, buffer.data(), length) ? makeOptional(String(buffer.data())) : WTF::nullopt;
-}
-
-void set(const String& variable, const String& value)
-{
-    ASSERT(!WTF::threadingIsInitialized());
-    ::SetEnvironmentVariableW(variable.charactersWithNullTermination().data(), value.charactersWithNullTermination().data());
-}
-
-void setIfNotDefined(const String& variable, const String& value)
-{
-    ASSERT(!WTF::threadingIsInitialized());
-    if (get(variable))
-        return;
-
-    set(variable, value);
-}
-
-void remove(const String& variable)
-{
-    ASSERT(!WTF::threadingIsInitialized());
-    ::SetEnvironmentVariableW(variable.charactersWithNullTermination().data(), nullptr);
-}
-
-} // namespace EnvironmentImpl
-} // namespace WTF
index 2a1ed8a..2141a8f 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-16  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] RenderImage's default intrinsic size is 0.
index cb28b2c..94d25c2 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-15  Ross Kirsling  <ross.kirsling@sony.com>
 
         [WTF] Add environment variable helpers
index a432bf7..24734f9 100644 (file)
 #include "config.h"
 #include "Logging.h"
 
-#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-#include <wtf/Environment.h>
 #include <wtf/text/WTFString.h>
 
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
 namespace PAL {
 
 String logLevelString()
 {
 #if !LOG_DISABLED
-    auto logEnv = Environment::get("WEBKIT_DEBUG");
-    if (!logEnv)
-        return emptyString();
+    if (char* logEnv = getenv("WEBKIT_DEBUG")) {
 
 #if defined(NDEBUG)
-    WTFLogAlways("WEBKIT_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build.");
+        WTFLogAlways("WEBCORE_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build.");
 #endif
 
-    // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1.
-    return makeString("NotYetImplemented,", *logEnv);
-#else
-    return String();
+        // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1.
+        return makeString("NotYetImplemented,"_s, logEnv);
+    }
 #endif
+    return String();
 }
 
 } // namespace PAL
index b68cc94..6b232c4 100644 (file)
@@ -29,7 +29,7 @@
 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
 
 #include <windows.h>
-#include <wtf/Environment.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/text/WTFString.h>
 
 namespace PAL {
@@ -37,7 +37,17 @@ namespace PAL {
 String logLevelString()
 {
 #if !LOG_DISABLED
-    return Environment::get("WebCoreLogging").valueOr(emptyString());
+    static char* const loggingEnvironmentVariable = "WebCoreLogging";
+    DWORD length = GetEnvironmentVariableA(loggingEnvironmentVariable, 0, 0);
+    if (!length)
+        return emptyString();
+
+    Vector<char> buffer(length);
+
+    if (!GetEnvironmentVariableA(loggingEnvironmentVariable, buffer.data(), length))
+        return emptyString();
+
+    return String(buffer.data());
 #else
     return String();
 #endif
index 250d433..72af706 100644 (file)
 #define NotImplemented_h
 
 #include <wtf/Assertions.h>
-#include <wtf/Environment.h>
 
 #if PLATFORM(GTK)
-#define suppressNotImplementedWarning() Environment::get("DISABLE_NI_WARNING")
+    #define suppressNotImplementedWarning() getenv("DISABLE_NI_WARNING")
 #else
-#define suppressNotImplementedWarning() false
+    #define suppressNotImplementedWarning() false
 #endif
 
 #if LOG_DISABLED
-#define notImplemented() ((void)0)
+    #define notImplemented() ((void)0)
 #else
 
 namespace WebCore {
index 3fac83d..d4c4f5a 100644 (file)
@@ -25,8 +25,6 @@
 #include "config.h"
 #include "SystemVersion.h"
 
-#include <wtf/Environment.h>
-
 namespace WebCore {
 
 static NSString *createSystemMarketingVersion()
@@ -34,7 +32,7 @@ static NSString *createSystemMarketingVersion()
     // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want.
     NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0];
 #if PLATFORM(IOS_FAMILY_SIMULATOR)
-    if (const char* simulatorRoot = Environment::getRaw("SIMULATOR_ROOT"))
+    if (char *simulatorRoot = getenv("SIMULATOR_ROOT"))
         systemLibraryPath = [NSString stringWithFormat:@"%s/%@", simulatorRoot, systemLibraryPath];
 #endif
     NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
index 29f23ba..1fa4c4c 100644 (file)
@@ -29,7 +29,6 @@
 #include <gst/audio/audio-info.h>
 #include <gst/gst.h>
 #include <mutex>
-#include <wtf/Environment.h>
 #include <wtf/glib/GLibUtilities.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/glib/RunLoopSourcePriority.h>
@@ -238,7 +237,8 @@ bool initializeGStreamer(Optional<Vector<String>>&& options)
         g_strfreev(argv);
 
         if (isFastMallocEnabled()) {
-            if (!Environment::hasValue("WEBKIT_GST_DISABLE_FAST_MALLOC", "0"))
+            const char* disableFastMalloc = getenv("WEBKIT_GST_DISABLE_FAST_MALLOC");
+            if (!disableFastMalloc || !strcmp(disableFastMalloc, "0"))
                 gst_allocator_set_default(GST_ALLOCATOR(g_object_new(gst_allocator_fast_malloc_get_type(), nullptr)));
         }
 
index 9e50cdc..d458f1a 100644 (file)
@@ -42,7 +42,6 @@
 #include <gst/gst.h>
 #include <gst/pbutils/missing-plugins.h>
 #include <limits>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/HexNumber.h>
 #include <wtf/MediaTime.h>
@@ -2418,7 +2417,7 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin(const gchar* playbinName, con
     ASSERT(!m_pipeline);
 
 #if GST_CHECK_VERSION(1, 10, 0)
-    if (Environment::get("USE_PLAYBIN3"))
+    if (g_getenv("USE_PLAYBIN3"))
         playbinName = "playbin3";
 #else
     playbinName = "playbin";
index 6263266..07ae7a2 100644 (file)
 
 #include "NicosiaPaintingEngineBasic.h"
 #include "NicosiaPaintingEngineThreaded.h"
-#include <wtf/Environment.h>
 
 namespace Nicosia {
 
 std::unique_ptr<PaintingEngine> PaintingEngine::create()
 {
 #if ENABLE(DEVELOPER_MODE) && PLATFORM(WPE)
-    if (auto numThreadsEnv = Environment::get("WEBKIT_NICOSIA_PAINTING_THREADS")) {
-        bool ok;
-        auto numThreads = numThreadsEnv->toIntStrict(&ok);
-        if (ok) {
+    if (const char* numThreadsEnv = getenv("WEBKIT_NICOSIA_PAINTING_THREADS")) {
+        unsigned numThreads = 0;
+        if (sscanf(numThreadsEnv, "%u", &numThreads) == 1) {
             if (numThreads < 1 || numThreads > 8) {
                 WTFLogAlways("The number of Nicosia painting threads is not between 1 and 8. Using the default value 4\n");
                 numThreads = 4;
index 6e51984..c8cac48 100644 (file)
 */
 
 #include "config.h"
+
 #include "TextureMapperFPSCounter.h"
 
 #include "TextureMapper.h"
-#include <wtf/Environment.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -34,13 +34,12 @@ TextureMapperFPSCounter::TextureMapperFPSCounter()
     , m_lastFPS(0)
     , m_frameCount(0)
 {
-    if (auto showFPSEnvironment = Environment::get("WEBKIT_SHOW_FPS")) {
-        bool ok;
-        m_fpsInterval = Seconds(showFPSEnvironment->toDouble(&ok));
-        if (ok && m_fpsInterval) {
-            m_isShowingFPS = true;
-            m_fpsTimestamp = MonotonicTime::now();
-        }
+    String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
+    bool ok = false;
+    m_fpsInterval = Seconds(showFPSEnvironment.toDouble(&ok));
+    if (ok && m_fpsInterval) {
+        m_isShowingFPS = true;
+        m_fpsTimestamp = MonotonicTime::now();
     }
 }
 
index 86a0652..8c81119 100644 (file)
@@ -27,7 +27,6 @@
 #include "PlatformDisplayX11.h"
 
 #include "GLContext.h"
-#include <wtf/Environment.h>
 
 #if PLATFORM(X11)
 #include <X11/Xlib.h>
@@ -45,7 +44,7 @@ namespace WebCore {
 
 std::unique_ptr<PlatformDisplay> PlatformDisplayX11::create()
 {
-    Display* display = XOpenDisplay(Environment::getRaw("DISPLAY"));
+    Display* display = XOpenDisplay(getenv("DISPLAY"));
     if (!display)
         return nullptr;
 
index d85dca1..b72c107 100644 (file)
@@ -28,7 +28,6 @@
 
 #if GTK_CHECK_VERSION(3, 20, 0)
 
-#include <wtf/Environment.h>
 #include <wtf/HashMap.h>
 #include <wtf/NeverDestroyed.h>
 
@@ -110,7 +109,7 @@ RenderThemeScrollbar::RenderThemeScrollbar(GtkOrientation orientation, Mode mode
         info.classList.append("horizontal");
         info.classList.append("bottom");
     }
-    static bool usesOverlayScrollbars = !Environment::hasValue("GTK_OVERLAY_SCROLLING", "0");
+    static bool usesOverlayScrollbars = g_strcmp0(g_getenv("GTK_OVERLAY_SCROLLING"), "0");
     if (usesOverlayScrollbars)
         info.classList.append("overlay-indicator");
     if (mode == Mode::Full)
index c3323b5..209af7b 100644 (file)
@@ -35,7 +35,6 @@
 #include "Scrollbar.h"
 #include <cstdlib>
 #include <gtk/gtk.h>
-#include <wtf/Environment.h>
 
 namespace WebCore {
 
@@ -56,7 +55,7 @@ static void themeChangedCallback()
 ScrollbarThemeGtk::ScrollbarThemeGtk()
 {
 #if GTK_CHECK_VERSION(3, 20, 0)
-    m_usesOverlayScrollbars = !Environment::hasValue("GTK_OVERLAY_SCROLLING", "0");
+    m_usesOverlayScrollbars = g_strcmp0(g_getenv("GTK_OVERLAY_SCROLLING"), "0");
 #endif
     static bool themeMonitorInitialized = false;
     if (!themeMonitorInitialized) {
index a2b8e8d..0ce1100 100644 (file)
@@ -35,7 +35,6 @@
 #include "HTTPHeaderMap.h"
 #include <NetworkLoadMetrics.h>
 #include <mutex>
-#include <wtf/Environment.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/CString.h>
 
 namespace WebCore {
 
+class EnvironmentVariableReader {
+public:
+    const char* read(const char* name) { return ::getenv(name); }
+    bool defined(const char* name) { return read(name) != nullptr; }
+
+    template<typename T> Optional<T> readAs(const char* name)
+    {
+        if (const char* valueStr = read(name)) {
+            T value;
+            if (sscanf(valueStr, sscanTemplate<T>(), &value) == 1)
+                return value;
+        }
+
+        return WTF::nullopt;
+    }
+
+private:
+    template<typename T> const char* sscanTemplate()
+    {
+        ASSERT_NOT_REACHED();
+        return nullptr;
+    }
+};
+
+template<>
+constexpr const char* EnvironmentVariableReader::sscanTemplate<signed>() { return "%d"; }
+
+template<>
+constexpr const char* EnvironmentVariableReader::sscanTemplate<unsigned>() { return "%u"; }
+
 // ALPN Protocol ID (RFC7301) https://tools.ietf.org/html/rfc7301
 static const ASCIILiteral httpVersion10 { "http/1.0"_s };
 static const ASCIILiteral httpVersion11 { "http/1.1"_s };
@@ -65,31 +94,34 @@ CurlContext::CurlContext()
 {
     initShareHandle();
 
-    if (auto value = Environment::getUInt("WEBKIT_CURL_DNS_CACHE_TIMEOUT"))
+    EnvironmentVariableReader envVar;
+
+    if (auto value = envVar.readAs<unsigned>("WEBKIT_CURL_DNS_CACHE_TIMEOUT"))
         m_dnsCacheTimeout = Seconds(*value);
 
-    if (auto value = Environment::getUInt("WEBKIT_CURL_CONNECT_TIMEOUT"))
+    if (auto value = envVar.readAs<unsigned>("WEBKIT_CURL_CONNECT_TIMEOUT"))
         m_connectTimeout = Seconds(*value);
 
     long maxConnects { CurlDefaultMaxConnects };
     long maxTotalConnections { CurlDefaultMaxTotalConnections };
     long maxHostConnections { CurlDefaultMaxHostConnections };
 
-    if (auto value = Environment::getInt("WEBKIT_CURL_MAXCONNECTS"))
+    if (auto value = envVar.readAs<signed>("WEBKIT_CURL_MAXCONNECTS"))
         maxConnects = *value;
 
-    if (auto value = Environment::getInt("WEBKIT_CURL_MAX_TOTAL_CONNECTIONS"))
+    if (auto value = envVar.readAs<signed>("WEBKIT_CURL_MAX_TOTAL_CONNECTIONS"))
         maxTotalConnections = *value;
 
-    if (auto value = Environment::getInt("WEBKIT_CURL_MAX_HOST_CONNECTIONS"))
+    if (auto value = envVar.readAs<signed>("WEBKIT_CURL_MAX_HOST_CONNECTIONS"))
         maxHostConnections = *value;
 
     m_scheduler = std::make_unique<CurlRequestScheduler>(maxConnects, maxTotalConnections, maxHostConnections);
 
 #ifndef NDEBUG
-    m_verbose = !!Environment::get("DEBUG_CURL");
+    m_verbose = envVar.defined("DEBUG_CURL");
 
-    if (const char* logFile = Environment::getRaw("CURL_LOG_FILE"))
+    auto logFile = envVar.read("CURL_LOG_FILE");
+    if (logFile)
         m_logFile = fopen(logFile, "a");
 #endif
 }
index c33e922..1ac4e02 100644 (file)
@@ -35,7 +35,6 @@
 #include "CurlContext.h"
 #include "NetworkingContext.h"
 #include "ResourceHandle.h"
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
@@ -47,8 +46,9 @@ namespace WebCore {
 static String defaultCookieJarPath()
 {
     static const char* defaultFileName = "cookie.jar.db";
-    if (auto cookieJarPath = Environment::get("CURL_COOKIE_JAR_PATH"))
-        return *cookieJarPath;
+    char* cookieJarPath = getenv("CURL_COOKIE_JAR_PATH");
+    if (cookieJarPath)
+        return cookieJarPath;
 
 #if PLATFORM(WIN)
     return FileSystem::pathByAppendingComponent(FileSystem::localUserSpecificStorageDirectory(), defaultFileName);
index 844aa66..3e1e287 100644 (file)
 #include "config.h"
 #include "CurlSSLHandle.h"
 
-#include <wtf/Environment.h>
-
 namespace WebCore {
 
 static String getCACertPathEnv()
 {
-    return Environment::get("CURL_CA_BUNDLE_PATH").valueOr(emptyString());
+    char* envPath = getenv("CURL_CA_BUNDLE_PATH");
+    if (envPath)
+        return { envPath };
+
+    return emptyString();
 }
 
 void CurlSSLHandle::platformInitialize()
index 395093f..47c88ba 100644 (file)
@@ -26,8 +26,6 @@
 #include "config.h"
 #include "CurlSSLHandle.h"
 
-#include <wtf/Environment.h>
-
 #if USE(CF)
 #if OS(WINDOWS)
 #include "WebCoreBundleWin.h"
@@ -40,8 +38,9 @@ namespace WebCore {
 
 static String getCACertPathEnv()
 {
-    if (auto envPath = Environment::get("CURL_CA_BUNDLE_PATH"))
-        return *envPath;
+    char* envPath = getenv("CURL_CA_BUNDLE_PATH");
+    if (envPath)
+        return String(envPath);
 
 #if USE(CF)
     CFBundleRef webKitBundleRef = webKitBundle();
index 5650df4..5eeb9bf 100644 (file)
@@ -32,7 +32,6 @@
 #include <hyphen.h>
 #include <limits>
 #include <stdlib.h>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/HashMap.h>
 #include <wtf/NeverDestroyed.h>
@@ -88,8 +87,8 @@ static void scanDirectoryForDictionaries(const char* directoryPath, HashMap<Atom
 #if ENABLE(DEVELOPER_MODE)
 static CString topLevelPath()
 {
-    if (auto topLevelDirectory = Environment::get("WEBKIT_TOP_LEVEL"))
-        return topLevelDirectory->utf8();
+    if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL"))
+        return topLevelDirectory;
 
     // If the environment variable wasn't provided then assume we were built into
     // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build
@@ -102,8 +101,9 @@ static CString topLevelPath()
 
 static CString webkitBuildDirectory()
 {
-    if (auto webkitOutputDir = Environment::get("WEBKIT_OUTPUTDIR"))
-        return webkitOutputDir->utf8();
+    const char* webkitOutputDir = g_getenv("WEBKIT_OUTPUTDIR");
+    if (webkitOutputDir)
+        return webkitOutputDir;
 
     GUniquePtr<char> outputDir(g_build_filename(topLevelPath().data(), "WebKitBuild", nullptr));
     return outputDir.get();
index 0d1e5a0..b72ad23 100644 (file)
@@ -24,7 +24,7 @@
 
 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
 
-#include <wtf/Environment.h>
+#include <string.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -32,7 +32,7 @@ namespace WebCore {
 String logLevelString()
 {
 #if !LOG_DISABLED
-    auto logEnv = Environment::get("WEBKIT_DEBUG");
+    char* logEnv = getenv("WEBKIT_DEBUG");
     if (!logEnv)
         return emptyString();
 
@@ -42,7 +42,7 @@ String logLevelString()
 #endif
 
     // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1.
-    return makeString("NotYetImplemented,", *logEnv);
+    return String("NotYetImplemented,") + logEnv;
 #else
     return String();
 #endif
index c158ed7..e6c444e 100644 (file)
@@ -29,7 +29,7 @@
 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
 
 #include <windows.h>
-#include <wtf/Environment.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -37,7 +37,17 @@ namespace WebCore {
 String logLevelString()
 {
 #if !LOG_DISABLED
-    return Environment::get("WebCoreLogging").valueOr(emptyString());
+    static char* const loggingEnvironmentVariable = "WebCoreLogging";
+    DWORD length = GetEnvironmentVariableA(loggingEnvironmentVariable, 0, 0);
+    if (!length)
+        return emptyString();
+
+    Vector<char> buffer(length);
+
+    if (!GetEnvironmentVariableA(loggingEnvironmentVariable, buffer.data(), length))
+        return emptyString();
+
+    return String(buffer.data());
 #else
     return String();
 #endif
index 8522ca4..5f9fed7 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-15  Youenn Fablet  <youenn@apple.com>
 
         NetworkDataTask should check its client before calling shouldCaptureExtraNetworkLoadMetrics
index 95f9f6b..736c017 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
 #include "NetworkProcessMainUnix.h"
 
-#include <wtf/Environment.h>
+#include <cstdlib>
 
 #if USE(GCRYPT)
 #include <pal/crypto/gcrypt/Initialization.h>
@@ -44,7 +43,7 @@ int main(int argc, char** argv)
     // overwrite this priority string if it's already set by the user.
     // https://bugzilla.gnome.org/show_bug.cgi?id=738633
     // WARNING: This needs to be KEPT IN SYNC with WebProcessMain.cpp.
-    Environment::setIfNotDefined("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128");
+    setenv("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128", 0);
 
 #if USE(GCRYPT)
     PAL::GCrypt::initialize();
index 09c1fca..5b17b3b 100644 (file)
 #include "config.h"
 #include "Logging.h"
 
-#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
-
-#include <wtf/Environment.h>
-#include <wtf/text/WTFString.h>
-
 namespace WebKit {
 
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
 String logLevelString()
 {
 #if !LOG_DISABLED
-    return Environment::get("WEBKIT_DEBUG").valueOr(emptyString());
+    return getenv("WEBKIT_DEBUG");
 #else
     return String();
 #endif
 }
 
-} // namespace WebKit
-
 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+}
index 31fd1be..69b0a5c 100644 (file)
@@ -30,7 +30,7 @@
 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
 
 #include <windows.h>
-#include <wtf/Environment.h>
+#include <wtf/StdLibExtras.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
@@ -38,7 +38,18 @@ namespace WebKit {
 String logLevelString()
 {
 #if !LOG_DISABLED
-    return Environment::get("WebKitLogging").valueOr(emptyString());
+    static char* const loggingEnvironmentVariable = "WebKitLogging";
+
+    DWORD length = GetEnvironmentVariableA(loggingEnvironmentVariable, 0, 0);
+    if (!length)
+        return emptyString();
+
+    Vector<char> buffer(length);
+
+    if (!GetEnvironmentVariableA(loggingEnvironmentVariable, buffer.data(), length))
+        return emptyString();
+
+    return String(buffer.data());
 #else
     return String();
 #endif
index 8d14144..1054e43 100644 (file)
@@ -53,7 +53,6 @@
 #import <pal/spi/mac/NSApplicationSPI.h>
 #import <pal/spi/mac/NSWindowSPI.h>
 #import <sysexits.h>
-#import <wtf/Environment.h>
 #import <wtf/HashSet.h>
 #import <wtf/NeverDestroyed.h>
 
@@ -169,8 +168,10 @@ static bool shouldCallRealDebugger()
     static bool isUserbreakSet = false;
     static dispatch_once_t flag;
     dispatch_once(&flag, ^{
-        if (auto var = Environment::getInt("USERBREAK"))
-            isUserbreakSet = *var;
+        char* var = getenv("USERBREAK");
+
+        if (var)
+            isUserbreakSet = atoi(var);
     });
     
     return isUserbreakSet;
index 3db3fd1..2bd549a 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "PluginSearchPath.h"
 
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 
 namespace WebKit {
@@ -37,15 +36,15 @@ Vector<String> pluginsDirectories()
     Vector<String> result;
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    auto mozillaPaths = Environment::get("MOZ_PLUGIN_PATH");
-    if (mozillaPaths && !mozillaPaths->isEmpty()) {
-        Vector<String> paths = mozillaPaths->split(':');
+    String mozillaPaths(getenv("MOZ_PLUGIN_PATH"));
+    if (!mozillaPaths.isEmpty()) {
+        Vector<String> paths = mozillaPaths.split(':');
         result.appendVector(paths);
     }
 
-    auto mozillaHome = Environment::get("MOZILLA_HOME");
-    if (mozillaHome && !mozillaHome->isEmpty())
-        result.append(*mozillaHome + "/plugins");
+    String mozillaHome(getenv("MOZILLA_HOME"));
+    if (!mozillaHome.isEmpty())
+        result.append(mozillaHome + "/plugins");
 
     result.append(FileSystem::homeDirectoryPath() + "/.mozilla/plugins");
     result.append(FileSystem::homeDirectoryPath() + "/.netscape/plugins");
index a29cd02..4ff35d3 100644 (file)
@@ -28,7 +28,6 @@
 #include "ProcessExecutablePath.h"
 
 #include <glib.h>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/glib/GLibUtilities.h>
 
@@ -47,9 +46,9 @@ static String getExecutablePath()
 static String findWebKitProcess(const char* processName)
 {
 #if ENABLE(DEVELOPER_MODE)
-    static auto execDirectory = Environment::get("WEBKIT_EXEC_PATH");
+    static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
     if (execDirectory) {
-        String processPath = FileSystem::pathByAppendingComponent(FileSystem::stringFromFileSystemRepresentation(execDirectory->utf8().data()), processName);
+        String processPath = FileSystem::pathByAppendingComponent(FileSystem::stringFromFileSystemRepresentation(execDirectory), processName);
         if (FileSystem::fileExists(processPath))
             return processPath;
     }
index a4119f0..03654dd 100644 (file)
@@ -40,7 +40,6 @@
 #include <WebCore/UserAgent.h>
 #include <cmath>
 #include <glib/gi18n-lib.h>
-#include <wtf/Environment.h>
 #include <wtf/glib/WTFGType.h>
 #include <wtf/text/CString.h>
 
@@ -184,7 +183,7 @@ static void webKitSettingsConstructed(GObject* object)
     WebPreferences* prefs = settings->priv->preferences.get();
     prefs->setShouldRespectImageOrientation(true);
 
-    if (Environment::get("WEBKIT_WEBRTC_DISABLE_UNIFIED_PLAN"))
+    if (g_getenv("WEBKIT_WEBRTC_DISABLE_UNIFIED_PLAN"))
         prefs->setWebRTCUnifiedPlanEnabled(FALSE);
 
     bool mediaStreamEnabled = prefs->mediaStreamEnabled();
@@ -336,7 +335,8 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
         if (g_value_get_boolean(value))
             webkit_settings_set_draw_compositing_indicators(settings, g_value_get_boolean(value));
         else {
-            auto showDebugVisuals = Environment::hasValue("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS", "1");
+            char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS");
+            bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1");
             webkit_settings_set_draw_compositing_indicators(settings, showDebugVisuals);
         }
         break;
index 7c62d4c..1ecbf38 100644 (file)
@@ -57,7 +57,6 @@
 #include <glib/gi18n-lib.h>
 #include <libintl.h>
 #include <memory>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/HashMap.h>
 #include <wtf/Language.h>
@@ -262,7 +261,7 @@ WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT)
 static const char* injectedBundleDirectory()
 {
 #if ENABLE(DEVELOPER_MODE)
-    const char* bundleDirectory = Environment::getRaw("WEBKIT_INJECTED_BUNDLE_PATH");
+    const char* bundleDirectory = g_getenv("WEBKIT_INJECTED_BUNDLE_PATH");
     if (bundleDirectory && g_file_test(bundleDirectory, G_FILE_TEST_IS_DIR))
         return bundleDirectory;
 #endif
@@ -360,7 +359,7 @@ static void webkitWebContextConstructed(GObject* object)
     priv->processPool->setIgnoreTLSErrors(false);
 
 #if ENABLE(MEMORY_SAMPLER)
-    if (Environment::get("WEBKIT_SAMPLE_MEMORY"))
+    if (getenv("WEBKIT_SAMPLE_MEMORY"))
         priv->processPool->startMemorySampler(0);
 #endif
 
index e9de041..8cafc7b 100644 (file)
@@ -29,7 +29,6 @@
 #include <WebCore/PlatformScreen.h>
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#include <wtf/Environment.h>
 
 gboolean webkitWebViewAuthenticate(WebKitWebView* webView, WebKitAuthenticationRequest* request)
 {
@@ -195,7 +194,8 @@ void webkitWebViewMaximizeWindow(WebKitWebView* view, CompletionHandler<void()>&
 #if ENABLE(DEVELOPER_MODE)
     // Xvfb doesn't support maximize, so we resize the window to the screen size.
     if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::X11) {
-        if (Environment::hasValue("UNDER_XVFB", "yes")) {
+        const char* underXvfb = g_getenv("UNDER_XVFB");
+        if (!g_strcmp0(underXvfb, "yes")) {
             auto screenRect = WebCore::screenAvailableRect(nullptr);
             gtk_window_move(window, screenRect.x(), screenRect.y());
             gtk_window_resize(window, screenRect.width(), screenRect.height());
@@ -247,7 +247,8 @@ void webkitWebViewRestoreWindow(WebKitWebView* view, CompletionHandler<void()>&&
 #if ENABLE(DEVELOPER_MODE)
     // Xvfb doesn't support maximize, so we resize the window to the default size.
     if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::X11) {
-        if (Environment::hasValue("UNDER_XVFB", "yes")) {
+        const char* underXvfb = g_getenv("UNDER_XVFB");
+        if (!g_strcmp0(underXvfb, "yes")) {
             int x, y;
             gtk_window_get_default_size(window, &x, &y);
             gtk_window_resize(window, x, y);
index d39eb77..eb13b43 100644 (file)
@@ -36,7 +36,6 @@
 #include "WebPageGroup.h"
 #include "WebProcessPool.h"
 #include <wpe/wpe.h>
-#include <wtf/Environment.h>
 
 using namespace WebKit;
 
@@ -71,7 +70,7 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC
     m_pageProxy = pool->createWebPage(*m_pageClient, WTFMove(configuration));
 
 #if ENABLE(MEMORY_SAMPLER)
-    if (Environment::get("WEBKIT_SAMPLE_MEMORY"))
+    if (getenv("WEBKIT_SAMPLE_MEMORY"))
         pool->startMemorySampler(0);
 #endif
 
index ffa034a..ca3789d 100644 (file)
@@ -27,7 +27,6 @@
 #include "AuxiliaryProcessProxy.h"
 
 #include "AuxiliaryProcessMessages.h"
-#include <wtf/Environment.h>
 #include <wtf/RunLoop.h>
 
 namespace WebKit {
@@ -52,8 +51,8 @@ void AuxiliaryProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& lau
 {
     launchOptions.processIdentifier = m_processIdentifier;
 
-    if (auto userDirectorySuffix = Environment::get("DIRHELPER_USER_DIR_SUFFIX"))
-        launchOptions.extraInitializationData.add("user-directory-suffix"_s, *userDirectorySuffix);
+    if (const char* userDirectorySuffix = getenv("DIRHELPER_USER_DIR_SUFFIX"))
+        launchOptions.extraInitializationData.add("user-directory-suffix"_s, userDirectorySuffix);
 
     if (m_alwaysRunsAtBackgroundPriority)
         launchOptions.extraInitializationData.add("always-runs-at-background-priority"_s, "true");
@@ -77,9 +76,9 @@ void AuxiliaryProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& lau
         ASSERT_NOT_REACHED();
         break;
     }
-    auto processCmdPrefix = Environment::get(varname);
-    if (processCmdPrefix && !processCmdPrefix->isEmpty())
-        launchOptions.processCmdPrefix = *processCmdPrefix;
+    const char* processCmdPrefix = getenv(varname);
+    if (processCmdPrefix && *processCmdPrefix)
+        launchOptions.processCmdPrefix = String::fromUTF8(processCmdPrefix);
 #endif // ENABLE(DEVELOPER_MODE) && (PLATFORM(GTK) || PLATFORM(WPE))
 
     platformGetLaunchOptions(launchOptions);
index 4f8a466..f8b102a 100644 (file)
@@ -25,7 +25,6 @@
 #include <glib.h>
 #include <seccomp.h>
 #include <sys/ioctl.h>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/glib/GLibUtilities.h>
 #include <wtf/glib/GRefPtr.h>
@@ -166,7 +165,7 @@ public:
             syncFdStr.get(),
         };
 
-        if (Environment::hasValue("WEBKIT_ENABLE_DBUS_PROXY_LOGGING", "1"))
+        if (!g_strcmp0(g_getenv("WEBKIT_ENABLE_DBUS_PROXY_LOGGING"), "1"))
             proxyArgs.append("--log");
 
         proxyArgs.appendVector(m_permissions);
@@ -283,7 +282,7 @@ static void bindIfExists(Vector<CString>& args, const char* path, BindFlags bind
 static void bindDBusSession(Vector<CString>& args, XDGDBusProxyLauncher& proxy)
 {
     if (!proxy.isRunning())
-        proxy.setAddress(Environment::getRaw("DBUS_SESSION_BUS_ADDRESS"), DBusAddressType::Normal);
+        proxy.setAddress(g_getenv("DBUS_SESSION_BUS_ADDRESS"), DBusAddressType::Normal);
 
     if (proxy.proxyPath().data()) {
         args.appendVector(Vector<CString>({
@@ -294,25 +293,25 @@ static void bindDBusSession(Vector<CString>& args, XDGDBusProxyLauncher& proxy)
 
 static void bindX11(Vector<CString>& args)
 {
-    const char* display = Environment::getRaw("DISPLAY");
+    const char* display = g_getenv("DISPLAY");
     if (!display || display[0] != ':' || !g_ascii_isdigit(const_cast<char*>(display)[1]))
         display = ":0";
     GUniquePtr<char> x11File(g_strdup_printf("/tmp/.X11-unix/X%s", display + 1));
     bindIfExists(args, x11File.get(), BindFlags::ReadWrite);
 
-    if (const char* xauth = Environment::getRaw("XAUTHORITY"))
-        bindIfExists(args, xauth);
-    else {
+    const char* xauth = g_getenv("XAUTHORITY");
+    if (!xauth) {
         const char* homeDir = g_get_home_dir();
         GUniquePtr<char> xauthFile(g_build_filename(homeDir, ".Xauthority", nullptr));
         bindIfExists(args, xauthFile.get());
-    }
+    } else
+        bindIfExists(args, xauth);
 }
 
 #if PLATFORM(WAYLAND) && USE(EGL)
 static void bindWayland(Vector<CString>& args)
 {
-    const char* display = Environment::getRaw("WAYLAND_DISPLAY");
+    const char* display = g_getenv("WAYLAND_DISPLAY");
     if (!display)
         display = "wayland-0";
 
@@ -326,7 +325,8 @@ static void bindPulse(Vector<CString>& args)
 {
     // FIXME: The server can be defined in config files we'd have to parse.
     // They can also be set as X11 props but that is getting a bit ridiculous.
-    if (const char* pulseServer = Environment::getRaw("PULSE_SERVER")) {
+    const char* pulseServer = g_getenv("PULSE_SERVER");
+    if (pulseServer) {
         if (g_str_has_prefix(pulseServer, "unix:"))
             bindIfExists(args, pulseServer + 5, BindFlags::ReadWrite);
         // else it uses tcp
@@ -336,7 +336,8 @@ static void bindPulse(Vector<CString>& args)
         bindIfExists(args, pulseRuntimeDir.get(), BindFlags::ReadWrite);
     }
 
-    if (const char* pulseConfig = Environment::getRaw("PULSE_CLIENTCONFIG"))
+    const char* pulseConfig = g_getenv("PULSE_CLIENTCONFIG");
+    if (pulseConfig)
         bindIfExists(args, pulseConfig);
 
     const char* configDir = g_get_user_config_dir();
@@ -449,7 +450,7 @@ static void bindA11y(Vector<CString>& args)
 
 static bool bindPathVar(Vector<CString>& args, const char* varname)
 {
-    const char* pathValue = Environment::getRaw(varname);
+    const char* pathValue = g_getenv(varname);
     if (!pathValue)
         return false;
 
@@ -476,8 +477,8 @@ static void bindGStreamerData(Vector<CString>& args)
     bindIfExists(args, gstCache.get(), BindFlags::ReadWrite);
 
     // /usr/lib is already added so this is only requried for other dirs
-    const char* scannerPath = Environment::getRaw("GST_PLUGIN_SCANNER") ?: "/usr/libexec/gstreamer-1.0/gst-plugin-scanner";
-    const char* helperPath = Environment::getRaw("GST_INSTALL_PLUGINS_HELPER ") ?: "/usr/libexec/gst-install-plugins-helper";
+    const char* scannerPath = g_getenv("GST_PLUGIN_SCANNER") ?: "/usr/libexec/gstreamer-1.0/gst-plugin-scanner";
+    const char* helperPath = g_getenv("GST_INSTALL_PLUGINS_HELPER ") ?: "/usr/libexec/gst-install-plugins-helper";
 
     bindIfExists(args, scannerPath);
     bindIfExists(args, helperPath);
@@ -719,12 +720,12 @@ GRefPtr<GSubprocess> bubblewrapSpawn(GSubprocessLauncher* launcher, const Proces
     // We would have to parse ld config files for more info.
     bindPathVar(sandboxArgs, "LD_LIBRARY_PATH");
 
-    auto libraryPath = Environment::get("LD_LIBRARY_PATH");
-    if (libraryPath && !libraryPath->isEmpty()) {
+    const char* libraryPath = g_getenv("LD_LIBRARY_PATH");
+    if (libraryPath && libraryPath[0]) {
         // On distros using a suid bwrap it drops this env var
         // so we have to pass it through to the children.
         sandboxArgs.appendVector(Vector<CString>({
-            "--setenv", "LD_LIBRARY_PATH", libraryPath->utf8(),
+            "--setenv", "LD_LIBRARY_PATH", libraryPath,
         }));
     }
 
@@ -803,8 +804,9 @@ GRefPtr<GSubprocess> bubblewrapSpawn(GSubprocessLauncher* launcher, const Proces
     }
 
 #if ENABLE(DEVELOPER_MODE)
-    if (auto execDirectory = Environment::get("WEBKIT_EXEC_PATH")) {
-        auto parentDir = FileSystem::directoryName(FileSystem::stringFromFileSystemRepresentation(execDirectory->utf8().data()));
+    const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
+    if (execDirectory) {
+        String parentDir = FileSystem::directoryName(FileSystem::stringFromFileSystemRepresentation(execDirectory));
         bindIfExists(sandboxArgs, parentDir.utf8().data());
     }
 
index 58022e1..0c39073 100644 (file)
@@ -34,7 +34,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <glib.h>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/RunLoop.h>
 #include <wtf/UniStdExtras.h>
@@ -166,10 +165,11 @@ void ProcessLauncher::launchProcess()
     GUniqueOutPtr<GError> error;
     GRefPtr<GSubprocess> process;
 #if OS(LINUX)
+    const char* sandboxEnv = g_getenv("WEBKIT_FORCE_SANDBOX");
     bool sandboxEnabled = m_launchOptions.extraInitializationData.get("enable-sandbox") == "true";
 
-    if (auto sandboxEnv = Environment::get("WEBKIT_FORCE_SANDBOX"))
-        sandboxEnabled = *sandboxEnv == "1";
+    if (sandboxEnv)
+        sandboxEnabled = !strcmp(sandboxEnv, "1");
 
     if (sandboxEnabled && isInsideFlatpak())
         process = flatpakSpawn(launcher.get(), m_launchOptions, argv, socketPair.client, &error.outPtr());
index 933f522..8964df3 100644 (file)
@@ -34,7 +34,6 @@
 #import <spawn.h>
 #import <sys/param.h>
 #import <sys/stat.h>
-#import <wtf/Environment.h>
 #import <wtf/MachSendRight.h>
 #import <wtf/RunLoop.h>
 #import <wtf/SoftLinking.h>
@@ -85,7 +84,7 @@ static NSString *systemDirectoryPath()
 {
     static NSString *path = [^{
 #if PLATFORM(IOS_FAMILY_SIMULATOR)
-        const char* simulatorRoot = Environment::getRaw("SIMULATOR_ROOT");
+        char *simulatorRoot = getenv("SIMULATOR_ROOT");
         return simulatorRoot ? [NSString stringWithFormat:@"%s/System/", simulatorRoot] : @"/System/";
 #else
         return @"/System/";
@@ -119,11 +118,11 @@ void ProcessLauncher::launchProcess()
 #if PLATFORM(IOS_FAMILY)
     // Clients that set these environment variables explicitly do not have the values automatically forwarded by libxpc.
     auto containerEnvironmentVariables = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
-    if (const char* environmentHOME = Environment::getRaw("HOME"))
+    if (const char* environmentHOME = getenv("HOME"))
         xpc_dictionary_set_string(containerEnvironmentVariables.get(), "HOME", environmentHOME);
-    if (const char* environmentCFFIXED_USER_HOME = Environment::getRaw("CFFIXED_USER_HOME"))
+    if (const char* environmentCFFIXED_USER_HOME = getenv("CFFIXED_USER_HOME"))
         xpc_dictionary_set_string(containerEnvironmentVariables.get(), "CFFIXED_USER_HOME", environmentCFFIXED_USER_HOME);
-    if (const char* environmentTMPDIR = Environment::getRaw("TMPDIR"))
+    if (const char* environmentTMPDIR = getenv("TMPDIR"))
         xpc_dictionary_set_string(containerEnvironmentVariables.get(), "TMPDIR", environmentTMPDIR);
     xpc_dictionary_set_value(initializationMessage.get(), "ContainerEnvironmentVariables", containerEnvironmentVariables.get());
 #endif
index 8cc3c96..a2a160b 100644 (file)
@@ -32,7 +32,6 @@
 #include "WebProcessCreationParameters.h"
 #include <JavaScriptCore/RemoteInspectorServer.h>
 #include <WebCore/GStreamerCommon.h>
-#include <wtf/Environment.h>
 #include <wtf/glib/GUniquePtr.h>
 
 namespace WebKit {
@@ -63,13 +62,14 @@ static void initializeRemoteInspectorServer(const char* address)
 
 static bool memoryPressureMonitorDisabled()
 {
-    return Environment::hasValue("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1");
+    static const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR");
+    return disableMemoryPressureMonitor && !strcmp(disableMemoryPressureMonitor, "1");
 }
 
 void WebProcessPool::platformInitialize()
 {
 #if ENABLE(REMOTE_INSPECTOR)
-    if (const char* address = Environment::getRaw("WEBKIT_INSPECTOR_SERVER"))
+    if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER"))
         initializeRemoteInspectorServer(address);
 #endif
 
@@ -89,7 +89,8 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters&
 #if PLATFORM(GTK)
     // This is misnamed. It can only be used to disable complex text.
     parameters.shouldAlwaysUseComplexTextCodePath = true;
-    if (Environment::hasValue("WEBKIT_FORCE_COMPLEX_TEXT", "0"))
+    const char* forceComplexText = getenv("WEBKIT_FORCE_COMPLEX_TEXT");
+    if (forceComplexText && !strcmp(forceComplexText, "0"))
         parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
 #endif
 
index 7366ea3..45760ee 100644 (file)
@@ -29,7 +29,6 @@
 #include "WaylandCompositor.h"
 #include <WebCore/NotImplemented.h>
 #include <WebCore/PlatformDisplay.h>
-#include <wtf/Environment.h>
 
 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
 #include <WebCore/PlatformDisplayX11.h>
@@ -53,7 +52,8 @@ HardwareAccelerationManager::HardwareAccelerationManager()
     return;
 #endif
 
-    if (Environment::hasValueOtherThan("WEBKIT_DISABLE_COMPOSITING_MODE", "0")) {
+    const char* disableCompositing = getenv("WEBKIT_DISABLE_COMPOSITING_MODE");
+    if (disableCompositing && strcmp(disableCompositing, "0")) {
         m_canUseHardwareAcceleration = false;
         return;
     }
@@ -78,7 +78,8 @@ HardwareAccelerationManager::HardwareAccelerationManager()
     }
 #endif
 
-    if (Environment::hasValueOtherThan("WEBKIT_FORCE_COMPOSITING_MODE", "0"))
+    const char* forceCompositing = getenv("WEBKIT_FORCE_COMPOSITING_MODE");
+    if (forceCompositing && strcmp(forceCompositing, "0"))
         m_forceHardwareAcceleration = true;
 }
 
index 1d9bafe..eedd442 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
 #include "WebProcessMainUnix.h"
 
-#include <wtf/Environment.h>
+#include <cstdlib>
 
 #if USE(GCRYPT)
 #include <pal/crypto/gcrypt/Initialization.h>
@@ -43,8 +42,8 @@ int main(int argc, char** argv)
     // GnuTLS or simply stops parsing this variable. We intentionally do not
     // overwrite this priority string if it's already set by the user.
     // https://bugzilla.gnome.org/show_bug.cgi?id=738633
-    // WARNING: This needs to be KEPT IN SYNC with NetworkProcessMain.cpp.
-    Environment::setIfNotDefined("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128");
+    // WARNING: This needs to be KEPT IN SYNC with WebProcessMain.cpp.
+    setenv("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128", 0);
 
 #if USE(GCRYPT)
     PAL::GCrypt::initialize();
index 10dccbb..b5f7ac4 100644 (file)
@@ -33,7 +33,6 @@
 #include <gtk/gtk.h>
 #include <libintl.h>
 #include <libsoup/soup.h>
-#include <wtf/Environment.h>
 
 #if PLATFORM(X11)
 #include <X11/Xlib.h>
@@ -47,7 +46,7 @@ public:
     bool platformInitialize() override
     {
 #ifndef NDEBUG
-        if (Environment::get("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH"))
+        if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH"))
             g_usleep(30 * G_USEC_PER_SEC);
 #endif
 
index ef4dfdb..13192b4 100644 (file)
@@ -34,7 +34,6 @@
 #include <iostream>
 #include <libsoup/soup.h>
 #include <wpe/wpe.h>
-#include <wtf/Environment.h>
 
 namespace WebKit {
 using namespace WebCore;
@@ -44,7 +43,7 @@ public:
     bool platformInitialize() override
     {
 #if ENABLE(DEVELOPER_MODE)
-        if (Environment::get("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH"))
+        if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH"))
             WTF::sleep(30_s);
 #endif
 
index a5457c3..054e711 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-15  Ross Kirsling  <ross.kirsling@sony.com>
 
         [WTF] Add environment variable helpers
index 61fbab9..ad6fe54 100644 (file)
@@ -38,7 +38,6 @@
 #import <WebCore/Settings.h>
 #import <WebCore/WebBackgroundTaskController.h>
 #import <WebCore/WebCoreThreadSystemInterface.h>
-#import <wtf/Environment.h>
 #import <wtf/spi/darwin/dyldSPI.h>
 
 using namespace WebCore;
@@ -107,7 +106,7 @@ const char *WebKitPlatformSystemRootDirectory(void)
 #if PLATFORM(IOS_FAMILY_SIMULATOR)
     static const char *platformSystemRootDirectory = nil;
     if (!platformSystemRootDirectory) {
-        const char* simulatorRoot = Environment::getRaw("IPHONE_SIMULATOR_ROOT");
+        char *simulatorRoot = getenv("IPHONE_SIMULATOR_ROOT");
         platformSystemRootDirectory = simulatorRoot ? simulatorRoot : "/";
     }
     return platformSystemRootDirectory;
index 727c4de..d7a3f6f 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-15  Ross Kirsling  <ross.kirsling@sony.com>
 
         [WTF] Add environment variable helpers
index 3e8d6b5..480f885 100644 (file)
 #import <pal/spi/mac/NSSpellCheckerSPI.h>
 #import <pal/spi/mac/NSWindowSPI.h>
 #import <wtf/Assertions.h>
-#import <wtf/Environment.h>
 #import <wtf/FileSystem.h>
 #import <wtf/HashTraits.h>
 #import <wtf/MainThread.h>
@@ -1607,7 +1606,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     // need for Safari to unset it to prevent it from being passed to applications it launches.
     // Unsetting it when a WebView is first created is as good a place as any.
     // See <http://bugs.webkit.org/show_bug.cgi?id=4286> for more details.
-    if (Environment::get("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH")) {
+    if (getenv("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH")) {
         unsetenv("DYLD_FRAMEWORK_PATH");
         unsetenv("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH");
     }
index 5470296..d9179aa 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-17  David Kilzer  <ddkilzer@apple.com>
+
+        Unreviewed, rolling out r241620.
+
+        "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
+        (Requested by ddkilzer on #webkit.)
+
+        Reverted changeset:
+
+        "[WTF] Add environment variable helpers"
+        https://bugs.webkit.org/show_bug.cgi?id=192405
+        https://trac.webkit.org/changeset/241620
+
 2019-02-16  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] RenderImage's default intrinsic size is 0.
index d79ecb3..b052412 100644 (file)
@@ -91,7 +91,6 @@
 #import <WebKit/WebViewPrivate.h>
 #import <getopt.h>
 #import <wtf/Assertions.h>
-#import <wtf/Environment.h>
 #import <wtf/FastMalloc.h>
 #import <wtf/LoggingAccumulator.h>
 #import <wtf/ObjCRuntimeExtras.h>
@@ -844,10 +843,11 @@ static void destroyWebViewAndOffscreenWindow(WebView *webView)
 
 static NSString *libraryPathForDumpRenderTree()
 {
-    if (const char* dumpRenderTreeTemp = Environment::getRaw("DUMPRENDERTREE_TEMP"))
+    char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP");
+    if (dumpRenderTreeTemp)
         return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:dumpRenderTreeTemp length:strlen(dumpRenderTreeTemp)];
-
-    return [@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath];
+    else
+        return [@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath];
 }
 
 static void enableExperimentalFeatures(WebPreferences* preferences)
index 107ad0c..3764fcd 100644 (file)
@@ -59,7 +59,6 @@
 #include <shlwapi.h>
 #include <tchar.h>
 #include <windows.h>
-#include <wtf/Environment.h>
 #include <wtf/FileSystem.h>
 #include <wtf/HashSet.h>
 #include <wtf/NeverDestroyed.h>
@@ -215,14 +214,16 @@ static string toUTF8(const wchar_t* wideString, size_t length)
 #if USE(CF)
 static String libraryPathForDumpRenderTree()
 {
-    auto path = Environment::get(dumpRenderTreeTemp);
-    if (!path || path->isEmpty())
-        return FileSystem::localUserSpecificStorageDirectory();
-
-    if (!path->endsWith('\\'))
-        path->append('\\');
+    DWORD size = ::GetEnvironmentVariable(dumpRenderTreeTemp, 0, 0);
+    Vector<TCHAR> buffer(size);
+    if (::GetEnvironmentVariable(dumpRenderTreeTemp, buffer.data(), buffer.size())) {
+        wstring path = buffer.data();
+        if (!path.empty() && (path[path.length() - 1] != L'\\'))
+            path.append(L"\\");
+        return String (path.data(), path.length());
+    }
 
-    return *path;
+    return FileSystem::localUserSpecificStorageDirectory();
 }
 #endif
 
index e2e6517..bc312bf 100644 (file)
@@ -32,7 +32,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <wtf/Assertions.h>
-#include <wtf/Environment.h>
 
 static int stdinSocket;
 static int stdoutSocket;
@@ -49,10 +48,11 @@ static int connectToServer(sockaddr_in& serverAddress)
 
 void setUpIOSLayoutTestCommunication()
 {
-    auto port = Environment::getInt("PORT");
-    if (!port)
+    char* portFromEnvironment = getenv("PORT");
+    if (!portFromEnvironment)
         return;
-    RELEASE_ASSERT(*port > 0);
+    int port = atoi(portFromEnvironment);
+    RELEASE_ASSERT(port > 0);
     isUsingTCP = true;
 
     struct hostent* host = gethostbyname("127.0.0.1");
@@ -63,7 +63,7 @@ void setUpIOSLayoutTestCommunication()
         (char*)&serverAddress.sin_addr.s_addr,
         (char*)host->h_addr,
         host->h_length);
-    serverAddress.sin_port = htons(*port);
+    serverAddress.sin_port = htons(port);
     
     // This order matches the server side listener in Tools/Scripts/webkitpy/port/simulator_process.py SimulatorProcess._start()
     stdinSocket = connectToServer(serverAddress);
index 13f20e2..998ab2f 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "TestMain.h"
 #include <gio/gio.h>
-#include <wtf/Environment.h>
 #include <wtf/UUID.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -344,7 +343,7 @@ static void testAutomationSessionApplicationInfo(Test* test, gconstpointer)
 
 void beforeAll()
 {
-    Environment::set("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2229");
+    g_setenv("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2229", TRUE);
 
     AutomationTest::add("WebKitAutomationSession", "request-session", testAutomationSessionRequestSession);
     Test::add("WebKitAutomationSession", "application-info", testAutomationSessionApplicationInfo);
index dd60b51..a155a51 100644 (file)
@@ -21,7 +21,6 @@
 #include "TestMain.h"
 
 #include <glib/gstdio.h>
-#include <wtf/Environment.h>
 
 #if PLATFORM(GTK)
 #include <gtk/gtk.h>
@@ -67,19 +66,19 @@ static void removeNonEmptyDirectory(const char* directoryPath)
 
 int main(int argc, char** argv)
 {
-    Environment::remove("DBUS_SESSION_BUS_ADDRESS");
+    g_unsetenv("DBUS_SESSION_BUS_ADDRESS");
 #if PLATFORM(GTK)
     gtk_test_init(&argc, &argv, nullptr);
 #else
     g_test_init(&argc, &argv, nullptr);
 #endif
-    Environment::setIfNotDefined("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH);
-    Environment::setIfNotDefined("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH);
-    Environment::set("LC_ALL", "C");
-    Environment::set("GIO_USE_VFS", "local");
-    Environment::set("GSETTINGS_BACKEND", "memory");
+    g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
+    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
+    g_setenv("LC_ALL", "C", TRUE);
+    g_setenv("GIO_USE_VFS", "local", TRUE);
+    g_setenv("GSETTINGS_BACKEND", "memory", TRUE);
     // Get rid of runtime warnings about deprecated properties and signals, since they break the tests.
-    Environment::set("G_ENABLE_DIAGNOSTIC", "0");
+    g_setenv("G_ENABLE_DIAGNOSTIC", "0", TRUE);
     g_test_bug_base("https://bugs.webkit.org/");
 
     registerGResource();
index 5a3d5c4..ba6476c 100644 (file)
@@ -20,8 +20,6 @@
 #include "config.h"
 #include "WebKitTestBus.h"
 
-#include <wtf/Environment.h>
-
 WebKitTestBus::WebKitTestBus()
     : m_bus(adoptGRef(g_test_dbus_new(G_TEST_DBUS_NONE)))
 {
@@ -34,14 +32,14 @@ WebKitTestBus::~WebKitTestBus()
 
 bool WebKitTestBus::run()
 {
-    auto display = Environment::get("DISPLAY");
-    auto runtimeDir = Environment::get("XDG_RUNTIME_DIR");
+    CString display = g_getenv("DISPLAY");
+    CString runtimeDir = g_getenv("XDG_RUNTIME_DIR");
     g_test_dbus_up(m_bus.get());
     m_address = g_test_dbus_get_bus_address(m_bus.get());
-    if (display)
-        Environment::setIfNotDefined("DISPLAY", *display);
-    if (runtimeDir)
-        Environment::setIfNotDefined("XDG_RUNTIME_DIR", *runtimeDir);
+    if (!display.isNull())
+        g_setenv("DISPLAY", display.data(), FALSE);
+    if (!runtimeDir.isNull())
+        g_setenv("XDG_RUNTIME_DIR", runtimeDir.data(), FALSE);
     return !m_address.isNull();
 }
 
index 5e8c69a..3f8e244 100644 (file)
@@ -34,7 +34,6 @@
 #include "InjectedBundleUtilities.h"
 #include <fontconfig/fontconfig.h>
 #include <gtk/gtk.h>
-#include <wtf/Environment.h>
 #include <wtf/glib/GLibUtilities.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -55,8 +54,9 @@ void initializeGtkSettings()
 
 CString getOutputDir()
 {
-    if (auto webkitOutputDir = Environment::get("WEBKIT_OUTPUTDIR"))
-        return webkitOutputDir->utf8();
+    const char* webkitOutputDir = g_getenv("WEBKIT_OUTPUTDIR");
+    if (webkitOutputDir)
+        return webkitOutputDir;
 
     CString topLevelPath = WTR::topLevelPath();
     GUniquePtr<char> outputDir(g_build_filename(topLevelPath.data(), "WebKitBuild", nullptr));
@@ -80,7 +80,7 @@ static CString getFontsPath()
 
 void initializeFontConfigSetting()
 {
-    if (Environment::get("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION"))
+    if (g_getenv("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION"))
         return;
 
     FcInit();
index 249812f..ba08431 100644 (file)
@@ -45,7 +45,8 @@ void InjectedBundle::platformInitialize(WKTypeRef)
     // messages sent to the logger.
     g_log_set_default_handler(logHandler, 0);
 
-    g_setenv("WEBKIT_TOP_LEVEL", TOP_LEVEL_DIR, FALSE);
+    if (!g_getenv("WEBKIT_TOP_LEVEL"))
+        g_setenv("WEBKIT_TOP_LEVEL", TOP_LEVEL_DIR, FALSE);
 }
 
 } // namespace WTR
index 9277766..afbd3f7 100644 (file)
@@ -30,7 +30,6 @@
 #include "InjectedBundleUtilities.h"
 
 #include <gtk/gtk.h>
-#include <wtf/Environment.h>
 #include <wtf/glib/GLibUtilities.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -38,8 +37,8 @@ namespace WTR {
 
 CString topLevelPath()
 {
-    if (auto topLevelDirectory = Environment::get("WEBKIT_TOP_LEVEL"))
-        return topLevelDirectory->utf8();
+    if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL"))
+        return topLevelDirectory;
 
     // If the environment variable wasn't provided then assume we were built into
     // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build
index 9d1ed80..a49c7a2 100644 (file)
@@ -27,7 +27,6 @@
 #include "ActivateFonts.h"
 
 #include <fontconfig/fontconfig.h>
-#include <wtf/Environment.h>
 #include <wtf/glib/GLibUtilities.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -35,8 +34,8 @@ namespace WTR {
 
 CString topLevelPath()
 {
-    if (auto topLevelDirectory = Environment::get("WEBKIT_TOP_LEVEL"))
-        return topLevelDirectory->utf8();
+    if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL"))
+        return topLevelDirectory;
 
     // If the environment variable wasn't provided then assume we were built into
     // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build
@@ -49,8 +48,9 @@ CString topLevelPath()
 
 CString getOutputDir()
 {
-    if (auto webkitOutputDir = Environment::get("WEBKIT_OUTPUTDIR"))
-        return webkitOutputDir->utf8();
+    const char* webkitOutputDir = g_getenv("WEBKIT_OUTPUTDIR");
+    if (webkitOutputDir)
+        return webkitOutputDir;
 
     GUniquePtr<char> outputDir(g_build_filename(topLevelPath().data(), "WebKitBuild", nullptr));
     return outputDir.get();
@@ -73,7 +73,7 @@ static CString getFontsPath()
 
 void activateFonts()
 {
-    if (Environment::get("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION"))
+    if (g_getenv("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION"))
         return;
 
     FcInit();
index aa89f2a..10aebcf 100644 (file)
@@ -72,7 +72,6 @@
 #include <string>
 #include <wtf/AutodrainedPool.h>
 #include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/Environment.h>
 #include <wtf/MainThread.h>
 #include <wtf/ProcessPrivilege.h>
 #include <wtf/RefCounted.h>
@@ -387,15 +386,15 @@ WKPageRef TestController::createOtherPage(PlatformWebView* parentView, WKPageCon
     return newPage;
 }
 
-String TestController::libraryPathForTesting()
+const char* TestController::libraryPathForTesting()
 {
     // FIXME: This may not be sufficient to prevent interactions/crashes
     // when running more than one copy of DumpRenderTree.
     // See https://bugs.webkit.org/show_bug.cgi?id=10906
-    if (auto dumpRenderTreeTemp = Environment::get("DUMPRENDERTREE_TEMP"))
-        return *dumpRenderTreeTemp;
-
-    return String::fromUTF8(platformLibraryPathForTesting());
+    char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP");
+    if (dumpRenderTreeTemp)
+        return dumpRenderTreeTemp;
+    return platformLibraryPathForTesting();
 }
 
 void TestController::initialize(int argc, const char* argv[])
@@ -462,8 +461,9 @@ WKRetainPtr<WKContextConfigurationRef> TestController::generateContextConfigurat
     WKContextConfigurationSetFullySynchronousModeIsAllowedForTesting(configuration.get(), true);
     WKContextConfigurationSetIgnoreSynchronousMessagingTimeoutsForTesting(configuration.get(), options.ignoreSynchronousMessagingTimeouts);
 
-    auto temporaryFolder = libraryPathForTesting();
-    if (!!temporaryFolder) {
+    if (const char* dumpRenderTreeTemp = libraryPathForTesting()) {
+        String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp);
+
         WKContextConfigurationSetApplicationCacheDirectory(configuration.get(), toWK(temporaryFolder + pathSeparator + "ApplicationCache").get());
         WKContextConfigurationSetDiskCacheDirectory(configuration.get(), toWK(temporaryFolder + pathSeparator + "Cache").get());
         WKContextConfigurationSetIndexedDBDatabaseDirectory(configuration.get(), toWK(temporaryFolder + pathSeparator + "Databases" + pathSeparator + "IndexedDB").get());
@@ -481,8 +481,9 @@ WKRetainPtr<WKPageConfigurationRef> TestController::generatePageConfiguration(WK
 
     m_geolocationProvider = std::make_unique<GeolocationProviderMock>(m_context.get());
 
-    auto temporaryFolder = libraryPathForTesting();
-    if (!!temporaryFolder) {
+    if (const char* dumpRenderTreeTemp = libraryPathForTesting()) {
+        String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp);
+
         // FIXME: This should be migrated to WKContextConfigurationRef.
         // Disable icon database to avoid fetching <http://127.0.0.1:8000/favicon.ico> and making tests flaky.
         // Invividual tests can enable it using testRunner.setIconDatabaseEnabled, although it's not currently supported in WebKitTestRunner.
@@ -1380,7 +1381,7 @@ static std::string contentExtensionJSONPath(WKURLRef url)
 #if ENABLE(CONTENT_EXTENSIONS)
 void TestController::configureContentExtensionForTest(const TestInvocation& test)
 {
-    auto contentExtensionsPath = libraryPathForTesting();
+    const char* contentExtensionsPath = libraryPathForTesting();
     if (!contentExtensionsPath)
         contentExtensionsPath = "/tmp/wktr-contentextensions";
 
@@ -1399,7 +1400,7 @@ void TestController::configureContentExtensionForTest(const TestInvocation& test
     std::string jsonFileContents {std::istreambuf_iterator<char>(jsonFile), std::istreambuf_iterator<char>()};
     auto jsonSource = adoptWK(WKStringCreateWithUTF8CString(jsonFileContents.c_str()));
 
-    auto storePath = adoptWK(WKStringCreateWithUTF8CString(contentExtensionsPath.utf8().data()));
+    auto storePath = adoptWK(WKStringCreateWithUTF8CString(contentExtensionsPath));
     auto extensionStore = adoptWK(WKUserContentExtensionStoreCreate(storePath.get()));
     ASSERT(extensionStore);
 
@@ -1422,13 +1423,13 @@ void TestController::resetContentExtensions()
 
     WKPageSetUserContentExtensionsEnabled(mainWebView()->page(), false);
 
-    auto contentExtensionsPath = libraryPathForTesting();
+    const char* contentExtensionsPath = libraryPathForTesting();
     if (!contentExtensionsPath)
         return;
 
     WKUserContentControllerRemoveAllUserContentFilters(userContentController());
 
-    auto storePath = adoptWK(WKStringCreateWithUTF8CString(contentExtensionsPath.utf8().data()));
+    auto storePath = adoptWK(WKStringCreateWithUTF8CString(contentExtensionsPath));
     auto extensionStore = adoptWK(WKUserContentExtensionStoreCreate(storePath.get()));
     ASSERT(extensionStore);
 
@@ -2278,11 +2279,12 @@ WKStringRef TestController::decideDestinationWithSuggestedFilename(WKContextRef,
         m_currentInvocation->outputText(builder.toString());
     }
 
-    auto temporaryFolder = libraryPathForTesting();
-    if (!temporaryFolder)
+    const char* dumpRenderTreeTemp = libraryPathForTesting();
+    if (!dumpRenderTreeTemp)
         return nullptr;
 
     *allowOverwrite = true;
+    String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp);
     if (suggestedFilename.isEmpty())
         suggestedFilename = "Unknown";
 
@@ -2826,9 +2828,11 @@ WKContextRef TestController::platformAdjustContext(WKContextRef context, WKConte
     auto* dataStore = WKContextGetWebsiteDataStore(context);
     WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(dataStore, true);
 
-    auto temporaryFolder = libraryPathForTesting();
-    if (!!temporaryFolder)
+    if (const char* dumpRenderTreeTemp = libraryPathForTesting()) {
+        String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp);
+
         WKWebsiteDataStoreSetServiceWorkerRegistrationDirectory(dataStore, toWK(temporaryFolder + pathSeparator + "ServiceWorkers").get());
+    }
 
     return context;
 }
index 74cb069..b43c55c 100644 (file)
@@ -37,7 +37,6 @@
 #include <wtf/Seconds.h>
 #include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 #if PLATFORM(COCOA)
 #include "ClassMethodSwizzler.h"
@@ -445,7 +444,7 @@ private:
     static void runModal(WKPageRef, const void* clientInfo);
     static void runModal(PlatformWebView*);
 
-    static String libraryPathForTesting();
+    static const char* libraryPathForTesting();
     static const char* platformLibraryPathForTesting();
 
     std::unique_ptr<TestInvocation> m_currentInvocation;
index 2765f6a..fe3bd6e 100644 (file)
@@ -108,11 +108,11 @@ void initializeWebViewConfiguration(const char* libraryPath, WKStringRef injecte
 
 void TestController::cocoaPlatformInitialize()
 {
-    auto dumpRenderTreeTemp = libraryPathForTesting();
+    const char* dumpRenderTreeTemp = libraryPathForTesting();
     if (!dumpRenderTreeTemp)
         return;
 
-    auto resourceLoadStatisticsFolder = makeString(dumpRenderTreeTemp, "/ResourceLoadStatistics");
+    String resourceLoadStatisticsFolder = String(dumpRenderTreeTemp) + '/' + "ResourceLoadStatistics";
     [[NSFileManager defaultManager] createDirectoryAtPath:resourceLoadStatisticsFolder withIntermediateDirectories:YES attributes:nil error: nil];
     String fullBrowsingSessionResourceLog = resourceLoadStatisticsFolder + '/' + "full_browsing_session_resourceLog.plist";
     NSDictionary *resourceLogPlist = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:1], @"version", nil];
@@ -207,7 +207,7 @@ PlatformWebView* TestController::platformCreateOtherPage(PlatformWebView* parent
 WKContextRef TestController::platformAdjustContext(WKContextRef context, WKContextConfigurationRef contextConfiguration)
 {
 #if WK_API_ENABLED
-    initializeWebViewConfiguration(libraryPathForTesting().utf8().data(), injectedBundlePath(), context, contextConfiguration);
+    initializeWebViewConfiguration(libraryPathForTesting(), injectedBundlePath(), context, contextConfiguration);
     return (__bridge WKContextRef)globalWebViewConfiguration.processPool;
 #else
     return nullptr;
index a4d18b3..a203956 100644 (file)
 #include "TestController.h"
 #include <WebKit/WKTextCheckerGtk.h>
 #include <gtk/gtk.h>
-#include <wtf/Environment.h>
 #include <wtf/glib/GRefPtr.h>
 
 int main(int argc, char** argv)
 {
-    Environment::setIfNotDefined("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1");
+    g_setenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1", FALSE);
 
     gtk_init(&argc, &argv);
 
index 6db4b25..3e773bc 100644 (file)
@@ -135,10 +135,10 @@ void TestController::configureContentExtensionForTest(const TestInvocation& test
     __block bool doneCompiling = false;
 
     NSURL *tempDir;
-    auto temporaryFolder = libraryPathForTesting();
-    if (!!temporaryFolder)
+    if (const char* dumpRenderTreeTemp = libraryPathForTesting()) {
+        String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp);
         tempDir = [NSURL fileURLWithPath:[(NSString*)temporaryFolder stringByAppendingPathComponent:@"ContentExtensions"] isDirectory:YES];
-    else
+    else
         tempDir = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"ContentExtensions"] isDirectory:YES];
 
     [[_WKUserContentExtensionStore storeWithURL:tempDir] compileContentExtensionForIdentifier:@"TestContentExtensions" encodedContentExtension:contentExtensionString completionHandler:^(_WKUserContentFilter *filter, NSError *error)
index 135bd25..d62269d 100644 (file)
 
 #include "TestController.h"
 #include <glib.h>
-#include <wtf/Environment.h>
 
 int main(int argc, char** argv)
 {
-    Environment::setIfNotDefined("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1");
+    g_setenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1", FALSE);
 
     WTR::TestController controller(argc, const_cast<const char**>(argv));
     return 0;