Bug 75064 - TestWebKitAPI: initialize the main thread before running tests
Summary: TestWebKitAPI: initialize the main thread before running tests
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-21 21:47 PST by David Kilzer (:ddkilzer)
Modified: 2012-01-04 11:26 PST (History)
3 users (show)

See Also:


Attachments
Patch v1 (1.55 KB, patch)
2011-12-21 21:55 PST, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2011-12-21 21:47:58 PST
Currently TestWebKitAPI doesn't initialize the main thread before running any tests.  This can lead to assertion failures in Debug builds when calling (for example) WebCore::UTF8Encoding() in a test.
Comment 1 David Kilzer (:ddkilzer) 2011-12-21 21:55:10 PST
Created attachment 120271 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2011-12-21 22:27:31 PST
Here's an example stack trace of such a crash:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000bbadbeef

VM Regions Near 0xbbadbeef:
--> 
    __TEXT                 0000000105fe7000-00000001060fd000 [ 1112K] r-x/rwx SM=COW  /Volumes/VOLUME/*

Application Specific Information:
objc[49579]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.JavaScriptCore            0x000000010792e203 WTF::isMainThread() + 195 (MainThreadMac.mm:144)
1   com.apple.WebCore                   0x00000001098a3efd _ZN7WebCoreL22buildBaseTextCodecMapsEv + 13 (TextEncodingRegistry.cpp:213)
2   com.apple.WebCore                   0x00000001098a3e2a WebCore::atomicCanonicalTextEncodingName(char const*) + 74 (TextEncodingRegistry.cpp:338)
3   com.apple.WebCore                   0x00000001098a2c21 WebCore::TextEncoding::TextEncoding(char const*) + 33 (TextEncoding.cpp:55)
4   com.apple.WebCore                   0x00000001098a2bed WebCore::TextEncoding::TextEncoding(char const*) + 29 (TextEncoding.cpp:58)
5   com.apple.WebCore                   0x00000001098a3598 WebCore::UTF8Encoding() + 40 (TextEncoding.cpp:250)
6   com.apple.WebCore                   0x000000010928e7b4 WebCore::decodeURLEscapeSequences(WTF::String const&) + 36 (KURL.cpp:919)
7   com.apple.WebCore                   0x000000010928e77a WebCore::KURL::host() const + 90 (KURL.cpp:586)
8   TestWebKitAPI                       0x0000000106073fbf TestWebKitAPI::WebCore_KURLConstCharConstructor_Test::TestBody() + 2015 (KURL.cpp:54)
9   TestWebKitAPI                       0x000000010607e7ca testing::Test::Run() + 154
10  TestWebKitAPI                       0x000000010607f0cd testing::internal::TestInfoImpl::Run() + 189
11  TestWebKitAPI                       0x000000010607f8fd testing::TestCase::Run() + 205
12  TestWebKitAPI                       0x00000001060849e9 testing::internal::UnitTestImpl::RunAllTests() + 793
13  TestWebKitAPI                       0x00000001060846c9 testing::UnitTest::Run() + 25
14  TestWebKitAPI                       0x0000000105fe9870 TestWebKitAPI::TestsController::run(int, char**) + 48 (TestsController.cpp:51)
15  TestWebKitAPI                       0x0000000105fe96e9 main + 121 (main.mm:35)
16  TestWebKitAPI                       0x0000000105fe8ca4 start + 52
Comment 3 WebKit Review Bot 2011-12-22 08:41:42 PST
Comment on attachment 120271 [details]
Patch v1

Clearing flags on attachment: 120271

Committed r103546: <http://trac.webkit.org/changeset/103546>
Comment 4 WebKit Review Bot 2011-12-22 08:41:46 PST
All reviewed patches have been landed.  Closing bug.
Comment 5 Sam Weinig 2011-12-25 12:31:38 PST
I am not sure I like this solution. Since one of the goals of this test runner is to test that the API works (and you wouldn't use this internal method when using API) this won't be testing if we forget to initialize threading for some API calls. 

Perhaps we can install some sort of helper for WebCore / JavaScriptCore internals tests that does the initialization only for them.
Comment 6 David Kilzer (:ddkilzer) 2012-01-04 11:02:01 PST
(In reply to comment #5)
> I am not sure I like this solution. Since one of the goals of this test runner is to test that the API works (and you wouldn't use this internal method when using API) this won't be testing if we forget to initialize threading for some API calls. 
> 
> Perhaps we can install some sort of helper for WebCore / JavaScriptCore internals tests that does the initialization only for them.

That's a great point.  I will back out this change and use a setup/helper function for the WebCore tests I'm writing.
Comment 7 David Kilzer (:ddkilzer) 2012-01-04 11:26:25 PST
(In reply to comment #6)
> (In reply to comment #5)
> > I am not sure I like this solution. Since one of the goals of this test runner is to test that the API works (and you wouldn't use this internal method when using API) this won't be testing if we forget to initialize threading for some API calls. 
> > 
> > Perhaps we can install some sort of helper for WebCore / JavaScriptCore internals tests that does the initialization only for them.
> 
> That's a great point.  I will back out this change and use a setup/helper function for the WebCore tests I'm writing.

Backed out in r104050:  <http://trac.webkit.org/changeset/104050>

Marking this bug as RESOLVED/WONTFIX.