| Summary: | MachineThreads should be ref counted | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Mark Lam <mark.lam> | ||||
| Component: | JavaScriptCore | Assignee: | Mark Lam <mark.lam> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | benjamin, fpizlo, ggaren, mark.lam, mmirman, msaboff, oliver, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Mark Lam
2015-02-05 18:25:30 PST
Created attachment 246146 [details]
the patch.
Comment on attachment 246146 [details] the patch. View in context: https://bugs.webkit.org/attachment.cgi?id=246146&action=review > Source/JavaScriptCore/API/tests/testapi.mm:507 > + while (!mainThreadIsReadyToJoin) > + sleep(1); This feels super shady. Comment on attachment 246146 [details] the patch. View in context: https://bugs.webkit.org/attachment.cgi?id=246146&action=review > Source/JavaScriptCore/API/tests/testapi.mm:1427 > + sleep(10); Eeek ... this is not supposed to be here. Leftover debugging code. Will remove. Comment on attachment 246146 [details]
the patch.
r=me but reduce the sleep(1) to something shorter, like a usleep(10000)
Thanks for the review. Reduced the sleep time as suggested. Landed in r179753: <http://trac.webkit.org/r179753>. Comment on attachment 246146 [details] the patch. View in context: https://bugs.webkit.org/attachment.cgi?id=246146&action=review > Source/JavaScriptCore/heap/Heap.cpp:350 > + // We need to remove the main thread explicitly here because the main thread > + // may not terminate for a while though the Heap (and VM) is being shut down. > + m_machineThreads->removeCurrentThread(); This is super weird. (1) The comment claims to be about the main thread, but this code runs on any thread. (2) A class that never called addCurrentThread calls removeCurrentThread, seemingly over-releasing a resource. > Source/JavaScriptCore/heap/MachineStackMarker.h:67 > + uint64_t m_magicNumber; // Only used for detecting use after free. Why is this better than using MallocScribble or libgmalloc? Comment on attachment 246146 [details] the patch. View in context: https://bugs.webkit.org/attachment.cgi?id=246146&action=review >> Source/JavaScriptCore/heap/MachineStackMarker.h:67 >> + uint64_t m_magicNumber; // Only used for detecting use after free. > > Why is this better than using MallocScribble or libgmalloc? Presumably lower cost in a debug build? After reading more into how pthread_key_delete() and _pthread_tsd_cleanup() works, we determined that this fix is invalid. Before the fix, there was indeed a race condition with a very small window that could result in a use after free scenario. I will roll out the patch and implement the fix from scratch with a different approach. r179753 was rolled out in r180591: <http://trac.webkit.org/r180591>. |