Changeset 178530 in webkit


Ignore:
Timestamp:
Jan 15, 2015 2:49:26 PM (9 years ago)
Author:
Brent Fulgham
Message:

[Win] Miscellaneous DRT fixes
https://bugs.webkit.org/show_bug.cgi?id=116562

Reviewed by Tim Horton.

While investigating the cause of several Windows crashes, I found:
(1) Messy conversions to and from BSTR types
(2) Weird mixes of wide-string and narrow string conversions
(3) Passing nullptr to some CoreFoundation routines that do not

permit null arguments.

(4) Commands to link the executable to the VS2005 runtime.

This patch cleans up these issues to improve DRT reliability on
Windows.

  • DumpRenderTree/cg/ImageDiffCG.cpp:

(main): Get rid of VS2005 runtime linking.

  • DumpRenderTree/win/DumpRenderTree.cpp:

(urlSuitableForTestResult): Protect against being asked
to process an empty URL.
(dumpHistoryItem): Do BSTR string building using _bstr_t, rather
than converting to/from wchar_t buffers.
(runTest): Simplify string and BSTR handling.
(createWebViewAndOffscreenWindow): Ditto.
(main): Get rid of VS2005 runtime linking.

  • DumpRenderTree/win/TestRunnerWin.cpp:

(jsStringRefToWString): Simplify code.
(TestRunner::pathToLocalResource):
(TestRunner::setUserStyleSheetLocation):

  • TestWebKitAPI/win/main.cpp: Get rid of

VS2005 runtime linking.

  • win/DLLLauncher/DLLLauncherMain.cpp:

(wWinMain): Ditto.

Location:
trunk/Tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r178528 r178530  
     12015-01-15  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win] Miscellaneous DRT fixes
     4        https://bugs.webkit.org/show_bug.cgi?id=116562
     5
     6        Reviewed by Tim Horton.
     7
     8        While investigating the cause of several Windows crashes, I found:
     9        (1) Messy conversions to and from BSTR types
     10        (2) Weird mixes of wide-string and narrow string conversions
     11        (3) Passing nullptr to some CoreFoundation routines that do not
     12            permit null arguments.
     13        (4) Commands to link the executable to the VS2005 runtime.
     14
     15        This patch cleans up these issues to improve DRT reliability on
     16        Windows.
     17
     18        * DumpRenderTree/cg/ImageDiffCG.cpp:
     19        (main): Get rid of VS2005 runtime linking.
     20        * DumpRenderTree/win/DumpRenderTree.cpp:
     21        (urlSuitableForTestResult): Protect against being asked
     22        to process an empty URL.
     23        (dumpHistoryItem): Do BSTR string building using _bstr_t, rather
     24        than converting to/from wchar_t buffers.
     25        (runTest): Simplify string and BSTR handling.
     26        (createWebViewAndOffscreenWindow): Ditto.
     27        (main): Get rid of VS2005 runtime linking.
     28        * DumpRenderTree/win/TestRunnerWin.cpp:
     29        (jsStringRefToWString): Simplify code.
     30        (TestRunner::pathToLocalResource):
     31        (TestRunner::setUserStyleSheetLocation):
     32        * TestWebKitAPI/win/main.cpp: Get rid of
     33        VS2005 runtime linking.
     34        * win/DLLLauncher/DLLLauncherMain.cpp:
     35        (wWinMain): Ditto.
     36
    1372015-01-15  Alexey Proskuryakov  <ap@apple.com>
    238
  • trunk/Tools/DumpRenderTree/cg/ImageDiffCG.cpp

    r174471 r178530  
    226226                if (CGImageGetWidth(actualImage.get()) != CGImageGetWidth(baselineImage.get()) || CGImageGetHeight(actualImage.get()) != CGImageGetHeight(baselineImage.get())) {
    227227#if OS(WINDOWS)
    228                     fprintf(stderr, "Error: test and reference images have different sizes. Test image is %zux%zu, reference image is %Iux%Iu\n",
     228                    fprintf(stderr, "Error: test and reference images have different sizes. Test image is %Iux%Iu, reference image is %Iux%Iu\n",
    229229#else
    230230                    fprintf(stderr, "Error: test and reference images have different sizes. Test image is %zux%zu, reference image is %zux%zu\n",
  • trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp

    r178139 r178530  
    4444
    4545#include <comutil.h>
     46#include <cstdio>
     47#include <cstring>
    4648#include <fcntl.h>
     49#include <fstream>
    4750#include <io.h>
    4851#include <math.h>
    4952#include <shlwapi.h>
    50 #include <stdio.h>
    51 #include <string.h>
    5253#include <tchar.h>
    5354#include <wtf/NeverDestroyed.h>
     
    6970
    7071#ifdef DEBUG_ALL
    71 const LPWSTR TestPluginDir = L"TestNetscapePlugin_Debug";
     72const _bstr_t TestPluginDir = L"TestNetscapePlugin_Debug";
    7273#else
    73 const LPWSTR TestPluginDir = L"TestNetscapePlugin";
     74const _bstr_t TestPluginDir = L"TestNetscapePlugin";
    7475#endif
    7576
     
    144145wstring urlSuitableForTestResult(const wstring& urlString)
    145146{
     147    if (urlString.empty())
     148        return urlString;
     149
    146150    RetainPtr<CFURLRef> url = adoptCF(CFURLCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(urlString.c_str()), urlString.length() * sizeof(wstring::value_type), kCFStringEncodingUTF16, 0));
    147151
     
    516520
    517521    if (wcsstr(static_cast<wchar_t*>(url), L"file:/") == static_cast<wchar_t*>(url)) {
    518         static wchar_t* layoutTestsString = L"/LayoutTests/";
    519         static wchar_t* fileTestString = L"(file test):";
     522        static wchar_t* layoutTestsStringUnixPath = L"/LayoutTests/";
     523        static wchar_t* layoutTestsStringDOSPath = L"\\LayoutTests\\";
    520524       
    521         wchar_t* result = wcsstr(static_cast<wchar_t*>(url), layoutTestsString);
    522         if (result == NULL)
     525        wchar_t* result = wcsstr(static_cast<wchar_t*>(url), layoutTestsStringUnixPath);
     526        if (!result)
     527            result = wcsstr(static_cast<wchar_t*>(url), layoutTestsStringDOSPath);
     528        if (!result)
    523529            return;
    524         wchar_t* start = result + wcslen(layoutTestsString);
    525 
    526         _bstr_t newURL(SysAllocStringLen(0, SysStringLen(url)), false);
    527         wcscpy(static_cast<wchar_t*>(newURL), fileTestString);
    528         wcscpy(static_cast<wchar_t*>(newURL) + wcslen(fileTestString), start);
    529 
    530         url = newURL;
     530
     531        wchar_t* start = result + wcslen(layoutTestsStringUnixPath);
     532
     533        url = _bstr_t(L"(file test):") + _bstr_t(start);
    531534    }
    532535
     
    10391042
    10401043    CFIndex length = CFStringGetLength(str);
    1041     UniChar* buffer = new UniChar[length + 1];
    1042 
    1043     CFStringGetCharacters(str, CFRangeMake(0, length), buffer);
    1044     buffer[length] = 0;
    1045 
    1046     _bstr_t urlBStr((OLECHAR*)buffer);
     1044
     1045    Vector<UniChar> buffer(length + 1, 0);
     1046    CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data());
     1047
     1048    _bstr_t urlBStr(reinterpret_cast<wchar_t*>(buffer.data()));
    10471049    ASSERT(urlBStr.length() == length);
    1048     delete[] buffer;
    10491050
    10501051    CFIndex maximumURLLengthAsUTF8 = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
    1051     char* testURL = new char[maximumURLLengthAsUTF8];
    1052     CFStringGetCString(str, testURL, maximumURLLengthAsUTF8, kCFStringEncodingUTF8);
     1052    Vector<char> testURL(maximumURLLengthAsUTF8 + 1, 0);
     1053    CFStringGetCString(str, testURL.data(), maximumURLLengthAsUTF8, kCFStringEncodingUTF8);
    10531054
    10541055    CFRelease(url);
     
    10561057    resetWebViewToConsistentStateBeforeTesting();
    10571058
    1058     ::gTestRunner = TestRunner::create(testURL, command.expectedPixelHash);
    1059     delete[] testURL;
     1059    ::gTestRunner = TestRunner::create(testURL.data(), command.expectedPixelHash);
    10601060    ::gTestRunner->setCustomTimeout(command.timeout);
    10611061    topLoadingFrame = nullptr;
     
    12211221    viewPrivate->setAlwaysUsesComplexTextCodePath(forceComplexText);
    12221222
    1223     _bstr_t pluginPath(SysAllocStringLen(0, exePath().length() + _tcslen(TestPluginDir)), false);
    1224     _tcscpy(static_cast<TCHAR*>(pluginPath), exePath().c_str());
    1225     _tcscat(static_cast<TCHAR*>(pluginPath), TestPluginDir);
    1226     if (FAILED(viewPrivate->addAdditionalPluginDirectory(pluginPath)))
     1223    _bstr_t pluginPath = _bstr_t(exePath().data()) + TestPluginDir;
     1224    if (FAILED(viewPrivate->addAdditionalPluginDirectory(pluginPath.GetBSTR())))
    12271225        return nullptr;
    12281226
     
    13851383int main(int argc, const char* argv[])
    13861384{
    1387 #ifdef _CRTDBG_MAP_ALLOC
    1388     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
    1389     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
    1390 #endif
    1391 
    13921385    // Cygwin calls ::SetErrorMode(SEM_FAILCRITICALERRORS), which we will inherit. This is bad for
    13931386    // testing/debugging, as it causes the post-mortem debugger not to be invoked. We reset the
  • trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp

    r178139 r178530  
    274274{
    275275    size_t length = JSStringGetLength(jsStr);
    276     Vector<WCHAR> buffer(length + 1);
     276    Vector<WCHAR> buffer(length + 1, 0);
    277277    memcpy(buffer.data(), JSStringGetCharactersPtr(jsStr), length * sizeof(WCHAR));
    278     buffer[length] = '\0';
     278    buffer[length] = 0;
    279279
    280280    return buffer.data();
     
    288288    if (!resolveCygwinPath(input, localPath)) {
    289289        printf("ERROR: Failed to resolve Cygwin path %S\n", input.c_str());
    290         return 0;
     290        return nullptr;
    291291    }
    292292
     
    767767
    768768    // The path has been resolved, now convert it back to a CFURL.
    769     int result = WideCharToMultiByte(CP_UTF8, 0, resultPath.c_str(), resultPath.size() + 1, 0, 0, 0, 0);
     769    int result = ::WideCharToMultiByte(CP_UTF8, 0, resultPath.c_str(), resultPath.size() + 1, nullptr, 0, nullptr, nullptr);
    770770    Vector<char> utf8Vector(result);
    771     result = WideCharToMultiByte(CP_UTF8, 0, resultPath.c_str(), resultPath.size() + 1, utf8Vector.data(), result, 0, 0);
     771    result = ::WideCharToMultiByte(CP_UTF8, 0, resultPath.c_str(), resultPath.size() + 1, utf8Vector.data(), result, nullptr, nullptr);
    772772    if (!result)
    773773        return;
  • trunk/Tools/TestWebKitAPI/win/main.cpp

    r151173 r178530  
    3939
    4040#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
    41 #if defined(_MSC_VER) && (_MSC_VER >= 1600)
    42 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.6195' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")
    43 #endif
    4441
    4542int main(int argc, char** argv)
  • trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp

    r178001 r178530  
    4949
    5050#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
    51 #if defined(_MSC_VER) && (_MSC_VER >= 1600) && !defined(WIN_CAIRO)
    52 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.6195' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")
    53 #endif
    5451
    5552static void enableTerminationOnHeapCorruption()
     
    188185#endif
    189186{
    190     _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF);
     187#ifdef _CRTDBG_MAP_ALLOC
     188    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
     189    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     190#endif
     191
     192    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);
    191193
    192194    enableTerminationOnHeapCorruption();
Note: See TracChangeset for help on using the changeset viewer.