| Summary: | Possible fix for JSC api test failures in debug mode after r187020. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | peavo | ||||
| Component: | Web Template Framework | Assignee: | Nobody <webkit-unassigned> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | achristensen, benjamin, bfulgham, cmarcelo, commit-queue, ddkilzer, fpizlo, ggaren, mark.lam, msaboff | ||||
| Priority: | P2 | ||||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
peavo
2015-07-20 08:24:02 PDT
Created attachment 257095 [details]
Patch
I have not been able to verify that this patch fixes the tests, since Windows is not using pthreads. Comment on attachment 257095 [details]
Patch
Thanks for your diagnosis of the bug. However, I do agree with the fix. Your approach still has a race condition where the same pthreadHandle can be added to the threadMap() twice. Let me take care of the bug since I can test it on mavericks.
(In reply to comment #3) > Comment on attachment 257095 [details] > Patch > > Thanks for your diagnosis of the bug. However, I do agree with the fix. > Your approach still has a race condition where the same pthreadHandle can be > added to the threadMap() twice. Let me take care of the bug since I can > test it on mavericks. Correction: I *don't* agree with the fix. (In reply to comment #3) > Comment on attachment 257095 [details] > Patch > > Thanks for your diagnosis of the bug. However, I do agree with the fix. > Your approach still has a race condition where the same pthreadHandle can be > added to the threadMap() twice. Let me take care of the bug since I can > test it on mavericks. Ok, thanks :) I dug into this, and see that Threading.cpp's threadEntryPoint() should have ensured that currentThread() is not called on the new thread until after the ThreadIdentifier has been established. Hence, Per's suspected race condition is not the root cause. We should roll out r187020 and r187021 until this issue is fixed. Rolled out r187020 and r187021 in r187026: <http://trac.webkit.org/r187026>. (In reply to comment #7) > Rolled out r187020 and r187021 in r187026: <http://trac.webkit.org/r187026>. Thanks for sorting this out, Mark :) And sorry for the noise, I can have a look, and see if I can spot other possible causes for the assert. Is this a possible scenario for the assert?
A thread not created with WTF::createThread() calls WTF::currentThread(), and then exits.
Next a thread created with WTF::createThread reuses the pthread_t handle, and then asserts.
For example, I see that JavaScriptCore\API\tests\testapi.mm is creating a thread using just pthread_create:
@autoreleasepool {
JSContext *context = [[JSContext alloc] init];
pthread_t threadID;
pthread_create(&threadID, NULL, &threadMain, (__bridge void*)context);
pthread_join(threadID, nullptr);
JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
checkResult(@"Did not crash after entering the VM from another thread", true);
}
(In reply to comment #9) > Is this a possible scenario for the assert? > > A thread not created with WTF::createThread() calls WTF::currentThread(), > and then exits. > Next a thread created with WTF::createThread reuses the pthread_t handle, > and then asserts. Yes, it looks like this is what's happening. I'm currently debugging the issue on Mavericks. (In reply to comment #10) > (In reply to comment #9) > > Is this a possible scenario for the assert? > > > > A thread not created with WTF::createThread() calls WTF::currentThread(), > > and then exits. > > Next a thread created with WTF::createThread reuses the pthread_t handle, > > and then asserts. > > Yes, it looks like this is what's happening. I'm currently debugging the > issue on Mavericks. The real problem has to do with a thread destructor bug in Mavericks too. All this brings to light that we should be using std::thread::id on every port except on Windows. I'll closed this bug as resolved since we rolled out the offending patches. I will work on a fix for bug 146448 that still allows Macs to use std::thread::id. (In reply to comment #11) > > The real problem has to do with a thread destructor bug in Mavericks too. > All this brings to light that we should be using std::thread::id on every > port except on Windows. I'll closed this bug as resolved since we rolled > out the offending patches. I will work on a fix for bug 146448 that still > allows Macs to use std::thread::id. Thanks! |