REOPENED 171865
Use Mach exceptions instead of signals where possible
https://bugs.webkit.org/show_bug.cgi?id=171865
Summary Use Mach exceptions instead of signals where possible
Keith Miller
Reported 2017-05-09 10:47:28 PDT
Use Mach exceptions instead of signals where possible
Attachments
WIP (35.47 KB, patch)
2017-05-09 10:47 PDT, Keith Miller
no flags
Patch (43.03 KB, patch)
2017-05-10 18:41 PDT, Keith Miller
no flags
Patch (43.90 KB, patch)
2017-05-10 20:05 PDT, Keith Miller
no flags
Patch (43.91 KB, patch)
2017-05-11 09:26 PDT, Keith Miller
no flags
Patch (45.75 KB, patch)
2017-05-11 10:43 PDT, Keith Miller
no flags
Patch (45.80 KB, patch)
2017-05-11 10:52 PDT, Keith Miller
no flags
Patch (47.35 KB, patch)
2017-05-11 11:28 PDT, Keith Miller
no flags
Patch (48.18 KB, patch)
2017-05-11 12:31 PDT, Keith Miller
no flags
Patch (48.99 KB, patch)
2017-05-11 13:25 PDT, Keith Miller
no flags
Patch (49.10 KB, patch)
2017-05-11 13:36 PDT, Keith Miller
no flags
Patch (49.11 KB, patch)
2017-05-11 13:43 PDT, Keith Miller
no flags
Patch (49.12 KB, patch)
2017-05-11 13:51 PDT, Keith Miller
no flags
Patch (49.12 KB, patch)
2017-05-11 13:52 PDT, Keith Miller
no flags
Patch (49.16 KB, patch)
2017-05-11 13:57 PDT, Keith Miller
no flags
Patch (49.20 KB, patch)
2017-05-11 14:06 PDT, Keith Miller
no flags
Patch (49.20 KB, patch)
2017-05-11 14:52 PDT, Keith Miller
no flags
Patch (48.92 KB, patch)
2017-05-11 15:49 PDT, Keith Miller
no flags
Patch (49.43 KB, patch)
2017-05-12 10:18 PDT, Keith Miller
no flags
Patch for landing (50.00 KB, patch)
2017-05-12 17:48 PDT, Keith Miller
no flags
Patch for landing (50.06 KB, patch)
2017-05-12 17:49 PDT, Keith Miller
no flags
Keith Miller
Comment 1 2017-05-09 10:47:53 PDT
Created attachment 309513 [details] WIP Passes at least one test
Mark Lam
Comment 2 2017-05-09 11:04:50 PDT
Comment on attachment 309513 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=309513&action=review > Source/JavaScriptCore/runtime/VMTraps.cpp:75 > - mcontext_t& mcontext; > + PlatformRegisters& context; I think it's better to rename this to registers. > Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp:81 > + SignalContext(WTF::PlatformRegisters& context) Don't need the WTF:: qualifier. And rename context to registers.
Keith Miller
Comment 3 2017-05-10 18:41:05 PDT
Build Bot
Comment 4 2017-05-10 18:43:30 PDT
Attachment 309673 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:125: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:131: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:137: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 5 in 19 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 5 2017-05-10 20:05:56 PDT
Build Bot
Comment 6 2017-05-10 20:07:38 PDT
Attachment 309680 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:125: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:131: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:137: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 5 in 19 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 7 2017-05-11 09:26:27 PDT
Build Bot
Comment 8 2017-05-11 09:28:08 PDT
Attachment 309715 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:125: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:131: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:137: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 5 in 19 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 9 2017-05-11 09:58:08 PDT
Comment on attachment 309715 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309715&action=review > Source/JavaScriptCore/runtime/Options.cpp:490 > + Please remove. > Source/JavaScriptCore/runtime/Options.h:448 > + v(bool, useBBQTierUpChecks, true, Normal, "Enables tier up checks for our BBQ code.") \ Is this meant for this patch? > Source/JavaScriptCore/wasm/WasmBBQPlan.cpp:245 > + TierUpCount* tierUp = Options::useBBQTierUpChecks() ? &m_tierUpCounts[functionIndex] : nullptr; Is this meant for this patch?
Mark Lam
Comment 10 2017-05-11 10:01:21 PDT
Comment on attachment 309715 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309715&action=review > Source/JavaScriptCore/runtime/Options.h:423 > + v(bool, useMachForExceptions, true, Normal, "Use mach exceptions rather than signals to handle faults and pass thread messages. (This does nothing on platforms without mach)") \ I think this is a bit misleading to be set to true all the time. An alternate way to do this is to default to false, but to override it to true in overrideDefaults() for OS(DARWIN) only. I think that that makes it clearer which platform uses this.
Keith Miller
Comment 11 2017-05-11 10:43:45 PDT
Build Bot
Comment 12 2017-05-11 10:44:49 PDT
Attachment 309722 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:125: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:131: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:137: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 5 in 21 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 13 2017-05-11 10:46:26 PDT
Comment on attachment 309722 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309722&action=review > Source/WTF/wtf/threads/Signals.cpp:33 > +extern "C" { > +#include "MachExceptionsServer.h" > +}; Need #if OS(DARWIN)? > Source/WTF/wtf/threads/Signals.cpp:40 > +#include <mach/mach.h> > +#include <mach/thread_act.h> Need #if OS(DARWIN).
Keith Miller
Comment 14 2017-05-11 10:52:08 PDT
Keith Miller
Comment 15 2017-05-11 10:52:44 PDT
(In reply to Mark Lam from comment #9) > Comment on attachment 309715 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=309715&action=review > > > Source/JavaScriptCore/runtime/Options.cpp:490 > > + > > Please remove. > > > Source/JavaScriptCore/runtime/Options.h:448 > > + v(bool, useBBQTierUpChecks, true, Normal, "Enables tier up checks for our BBQ code.") \ > > Is this meant for this patch? Yeah. > > > Source/JavaScriptCore/wasm/WasmBBQPlan.cpp:245 > > + TierUpCount* tierUp = Options::useBBQTierUpChecks() ? &m_tierUpCounts[functionIndex] : nullptr; > > Is this meant for this patch? Ditto.
Build Bot
Comment 16 2017-05-11 10:54:33 PDT
Attachment 309726 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 21 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 17 2017-05-11 11:28:19 PDT
Build Bot
Comment 18 2017-05-11 11:30:52 PDT
Attachment 309732 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 22 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 19 2017-05-11 12:31:51 PDT
Build Bot
Comment 20 2017-05-11 13:05:31 PDT
Attachment 309751 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 23 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 21 2017-05-11 13:25:47 PDT
Build Bot
Comment 22 2017-05-11 13:28:27 PDT
Attachment 309763 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 23 2017-05-11 13:36:59 PDT
Build Bot
Comment 24 2017-05-11 13:40:10 PDT
Attachment 309768 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 25 2017-05-11 13:43:41 PDT
Build Bot
Comment 26 2017-05-11 13:46:58 PDT
Attachment 309769 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 27 2017-05-11 13:51:19 PDT
Keith Miller
Comment 28 2017-05-11 13:52:57 PDT
Build Bot
Comment 29 2017-05-11 13:55:22 PDT
Attachment 309774 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 30 2017-05-11 13:57:11 PDT
Build Bot
Comment 31 2017-05-11 13:59:11 PDT
Attachment 309776 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 32 2017-05-11 14:06:10 PDT
Build Bot
Comment 33 2017-05-11 14:09:14 PDT
Attachment 309780 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Keith Miller
Comment 34 2017-05-11 14:52:07 PDT
Build Bot
Comment 35 2017-05-11 14:54:56 PDT
Attachment 309790 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:424: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 36 2017-05-11 15:03:13 PDT
Comment on attachment 309790 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309790&action=review > Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:35 > +#include <dispatch/dispatch.h> Needs #if OS(DARWIN). You should also enclose the new test section in #if OS(DARWIN). We need to keep the Windows build green.
Mark Lam
Comment 37 2017-05-11 15:34:00 PDT
Comment on attachment 309790 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309790&action=review > Source/JavaScriptCore/runtime/VMTraps.cpp:75 > + PlatformRegisters& context; Please rename "context" to "registers". > Source/JavaScriptCore/runtime/VMTraps.cpp:137 > + dataLogLn("trapping pc: ", RawPointer(context.trapPC), " jit start: ", startOfFixedExecutableMemoryPool, " jit end: ", endOfFixedExecutableMemoryPool); This should be conditional on "if (verbose)". I don't think we want the signal handler logging stuff normally. > Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp:82 > + SignalContext(PlatformRegisters& context) > + : context(context) Let's rename "context" to "registers". > Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp:136 > + PlatformRegisters& context; Ditto. > Source/WTF/wtf/ThreadMessage.cpp:201 > +void deliverMessagesUsingMach() { useMach = true; } Please fix for Webkit style requirements. > Source/WTF/wtf/ThreadMessage.cpp:212 > + return MessageStatus::ThreadExited; Unreachable code.
Keith Miller
Comment 38 2017-05-11 15:49:21 PDT
Comment on attachment 309790 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309790&action=review >> Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:35 >> +#include <dispatch/dispatch.h> > > Needs #if OS(DARWIN). You should also enclose the new test section in #if OS(DARWIN). We need to keep the Windows build green. I wrapped it in HAVE(MACH_EXCEPTIONS) >> Source/JavaScriptCore/runtime/VMTraps.cpp:75 >> + PlatformRegisters& context; > > Please rename "context" to "registers". Fixed. >> Source/JavaScriptCore/runtime/VMTraps.cpp:137 >> + dataLogLn("trapping pc: ", RawPointer(context.trapPC), " jit start: ", startOfFixedExecutableMemoryPool, " jit end: ", endOfFixedExecutableMemoryPool); > > This should be conditional on "if (verbose)". I don't think we want the signal handler logging stuff normally. I removed it, that's old debugging code. >> Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp:82 >> + : context(context) > > Let's rename "context" to "registers". fixed. >> Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp:136 >> + PlatformRegisters& context; > > Ditto. fixed. >> Source/WTF/wtf/ThreadMessage.cpp:201 >> +void deliverMessagesUsingMach() { useMach = true; } > > Please fix for Webkit style requirements. fixed. >> Source/WTF/wtf/ThreadMessage.cpp:212 >> + return MessageStatus::ThreadExited; > > Unreachable code. Whoops, fixed.
Keith Miller
Comment 39 2017-05-11 15:49:32 PDT
Build Bot
Comment 40 2017-05-11 15:50:27 PDT
Attachment 309803 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:428: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:129: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:135: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:141: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 41 2017-05-11 16:57:51 PDT
Comment on attachment 309803 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309803&action=review Mostly LGTM, just a few comments/questions. Also a suggestion for a test: Start 10-20 workers running Wasm, have each worker run for a few seconds, and just continually do OOB accesses such that we keep hitting the mach message handler. > Source/WTF/ChangeLog:22 > + I would add a link here to some of the overview you sent me. > Source/JavaScriptCore/runtime/Options.cpp:361 > +#if HAVE(MACH_EXCEPTIONS) > + Options::useMachForExceptions() = true; > +#endif Why is this needed since this already defaults to true? > Source/WTF/wtf/Platform.h:666 > +#if __has_include(<mach/mach_exc.defs>) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV)) Is this true on iOS? What about EWS bots? > Source/WTF/wtf/ThreadMessage.cpp:168 > + auto result = thread.suspend(); Nit: a type here would be helpful > Source/WTF/wtf/ThreadMessage.cpp:194 > + thread_set_state(thread.machThread(), flavor, (thread_state_t)&registers, userCount); style nit: Please you static_cast here. > Source/WTF/wtf/threads/Signals.cpp:64 > +static constexpr size_t maxMessageSize = 1 * KB; This is scary. Can we make sure there is no number defined somewhere that is more precise? > Source/WTF/wtf/threads/Signals.cpp:66 > +static void startMachExceptionHandlerThread() suggestion: I think adding a link to some of the documentation/overview of mach ports would be helpful. > Source/WTF/wtf/threads/Signals.cpp:73 > + if (mach_port_insert_right(mach_task_self(), exceptionPort, exceptionPort, MACH_MSG_TYPE_MAKE_SEND)!= KERN_SUCCESS) style nit: Need space around "!=" > Source/WTF/wtf/threads/Signals.cpp:76 > + // FIXME: This should use a dispatch queue. please link a bug or remove. > Source/WTF/wtf/threads/Signals.cpp:77 > + (void)Thread::create( Do we need this here because unused there is a compiler warning for unused? > Source/WTF/wtf/threads/Signals.cpp:95 > + dataLogLn("Failed to receive mach message due to ", mach_error_string(messageResult)); Do we ever expect this to happen? > Source/WTF/wtf/threads/Signals.cpp:155 > + dataLogLn("receivedSignal ", exceptionType); > + dataLogLn("Thread: ", exceptionData[0]); Remove. > Source/WTF/wtf/threads/Signals.cpp:159 > + *outStateCount = inStateCount; what does this count mean? > Source/WTF/wtf/threads/Signals.cpp:178 > + info.faultingAddress = reinterpret_cast<void*>(exceptionData[1]); Do we not care about this for SigIll? > Source/WTF/wtf/threads/Signals.cpp:184 > + dataLogLn(static_cast<int>(handlerResult)); remove > Source/WTF/wtf/threads/Signals.cpp:187 > + didHandle = true; Do we want to bail out here now that it's handled? > Source/WTF/wtf/threads/Signals.cpp:252 > + if (signal == Signal::Bus && useMach) What about SegV? > Source/WTF/wtf/threads/Signals.cpp:254 > + ASSERT(!useMach || signal != Signal::Usr); Why does this assertion hold given he above check?
Build Bot
Comment 42 2017-05-11 17:47:19 PDT
Comment on attachment 309803 [details] Patch Attachment 309803 [details] did not pass jsc-ews (mac): Output: http://webkit-queues.webkit.org/results/3721774 New failing tests: wasm.yaml/wasm/function-tests/trap-store.js.wasm-eager-jettison wasm.yaml/wasm/function-tests/trap-store.js.wasm-no-call-ic wasm.yaml/wasm/function-tests/trap-store.js.default-wasm
Keith Miller
Comment 43 2017-05-12 10:18:26 PDT
Build Bot
Comment 44 2017-05-12 10:19:56 PDT
Attachment 309908 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:428: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:137: catch_mach_exception_raise is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:143: catch_mach_exception_raise_state_identity is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] ERROR: Source/WTF/wtf/threads/Signals.cpp:149: catch_mach_exception_raise_state is incorrectly named. Don't use underscores in your identifier names. [readability/naming/underscores] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 45 2017-05-12 17:20:10 PDT
Comment on attachment 309908 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309908&action=review r=me with fixes. > Source/WTF/ChangeLog:11 > + that port in a thread. When another thread raises a exception (say /a exception/an exception/ > Source/WTF/ChangeLog:20 > + simply suspending the thread then running the message at that /thread then/thread, and then/. > Source/WTF/ChangeLog:23 > + You can read more abount mach exceptions here: /abount/about/ > Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:93 > +bool dispatchTerminateCallbackCalled = false; > +static bool dispatchTermitateCallback(JSContextRef, void*) > +{ > + dispatchTerminateCallbackCalled = true; > + return true; > +} You should enclose this in #if HAVE(MACH_EXCEPTIONS) too because the static function dispatchTermitateCallback is not used otherwise. If we ever force HAVE(MACH_EXCEPTIONS) to be false for a test build, we'll get a build failure due to this. > Source/JavaScriptCore/runtime/Options.h:423 > + v(bool, useMachForExceptions, true, Normal, "Use mach exceptions rather than signals to handle faults and pass thread messages. (This does nothing on platforms without mach)") \ Should default to false. We override it to true only when HAVE(MACH_EXCEPTIONS) in overrideDefaults(). > Source/WTF/wtf/ThreadMessage.cpp:94 > + installSignalHandler(signal, [] (Signal, SigInfo&, PlatformRegisters& context) { Rename context to registers. > Source/WTF/wtf/ThreadMessage.cpp:104 > + data->message(context); Ditto. > Source/WTF/wtf/ThreadMessage.cpp:214 > +#if HAVE(MACH_EXCEPTIONS) > + if (useMach) > + return sendMessageMach(thread, message); > +#endif > + return sendMessageSignal(thread, message); suggestion: sendMessageViaMach instead of sendMessageMach, and sendMessageViaSignal instead of sendMessageSignal? > Source/WTF/wtf/threads/Signals.cpp:63 > +// You can read more abount mach exceptions here: typo: /abount/about/. > Source/WTF/wtf/threads/Signals.cpp:196 > + switch (handlerResult) { > + case SignalAction::Handled: > + didHandle = true; > + break; > + default: > + break; > + } You can just say: didHandle = didHandle || (handlerResult == SignalAction::Handled); > Source/WTF/wtf/threads/Signals.cpp:232 > +void registerThread(Thread* thread) Let's name this "registerThreadForMachExceptionHandling" so that it adds some context in the client code on what the registration is for. > Source/WTF/wtf/threads/Signals.cpp:241 > +void removeThread(Thread* thread) small nit: I'd prefer "unregisterThread" to match "registerThread" simply for symmetry. So, let's name this "unregisterThreadForMachExceptionHandling". > Source/WTF/wtf/threads/Signals.cpp:257 > + if (signal == Signal::Bus && useMach) We should get rid of Signal::Bus as an option that the client can select, and force the signal version to make the Signal::Segv handler handle SIGBUS as well. For now, just add a FIXME with bug url to fix that later. Maybe rename Signal::Segv to Signal::BadAccess. > Source/WTF/wtf/threads/Signals.h:107 > +using WTF::SigInfo; Somewhere below this, you should add: #if HAVE(MACH_EXCEPTIONS) using WTF::registerThreadForMachExceptionHandling; using WTF::unregisterThreadForMachExceptionHandling; #endif The webkit way is to not have to qualify WTF APIs with WTF:: in the client code. Also using more descriptive names make it clearer what the registration is for in client code.
Keith Miller
Comment 46 2017-05-12 17:48:20 PDT
Comment on attachment 309908 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309908&action=review Thanks for the review! >> Source/WTF/ChangeLog:11 >> + that port in a thread. When another thread raises a exception (say > > /a exception/an exception/ Fixed. >> Source/WTF/ChangeLog:20 >> + simply suspending the thread then running the message at that > > /thread then/thread, and then/. Fixed. >> Source/WTF/ChangeLog:23 >> + You can read more abount mach exceptions here: > > /abount/about/ Fixed. >> Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp:93 >> +} > > You should enclose this in #if HAVE(MACH_EXCEPTIONS) too because the static function dispatchTermitateCallback is not used otherwise. If we ever force HAVE(MACH_EXCEPTIONS) to be false for a test build, we'll get a build failure due to this. Fixed. >> Source/JavaScriptCore/runtime/Options.h:423 >> + v(bool, useMachForExceptions, true, Normal, "Use mach exceptions rather than signals to handle faults and pass thread messages. (This does nothing on platforms without mach)") \ > > Should default to false. We override it to true only when HAVE(MACH_EXCEPTIONS) in overrideDefaults(). I think it makes more sense to override to false when there is no Mach exception capability. Making it false here would make me think it's actually not running by default. >> Source/WTF/wtf/ThreadMessage.cpp:94 >> + installSignalHandler(signal, [] (Signal, SigInfo&, PlatformRegisters& context) { > > Rename context to registers. Fixed. >> Source/WTF/wtf/ThreadMessage.cpp:104 >> + data->message(context); > > Ditto. Fixed. >> Source/WTF/wtf/ThreadMessage.cpp:214 >> + return sendMessageSignal(thread, message); > > suggestion: sendMessageViaMach instead of sendMessageMach, and sendMessageViaSignal instead of sendMessageSignal? Fair enough. I changed it to sendMessageUsingMach/UsingSignal since that's more consistent with the naming I used elsewhere. >> Source/WTF/wtf/threads/Signals.cpp:63 >> +// You can read more abount mach exceptions here: > > typo: /abount/about/. Fixed. >> Source/WTF/wtf/threads/Signals.cpp:196 >> + } > > You can just say: > didHandle = didHandle || (handlerResult == SignalAction::Handled); Changed. I did |= though. >> Source/WTF/wtf/threads/Signals.cpp:232 >> +void registerThread(Thread* thread) > > Let's name this "registerThreadForMachExceptionHandling" so that it adds some context in the client code on what the registration is for. Fair enough. Changed. >> Source/WTF/wtf/threads/Signals.cpp:241 >> +void removeThread(Thread* thread) > > small nit: I'd prefer "unregisterThread" to match "registerThread" simply for symmetry. So, let's name this "unregisterThreadForMachExceptionHandling". Sounds good. >> Source/WTF/wtf/threads/Signals.cpp:257 >> + if (signal == Signal::Bus && useMach) > > We should get rid of Signal::Bus as an option that the client can select, and force the signal version to make the Signal::Segv handler handle SIGBUS as well. For now, just add a FIXME with bug url to fix that later. Maybe rename Signal::Segv to Signal::BadAccess. Done. >> Source/WTF/wtf/threads/Signals.h:107 >> +using WTF::SigInfo; > > Somewhere below this, you should add: > #if HAVE(MACH_EXCEPTIONS) > using WTF::registerThreadForMachExceptionHandling; > using WTF::unregisterThreadForMachExceptionHandling; > #endif > > The webkit way is to not have to qualify WTF APIs with WTF:: in the client code. Also using more descriptive names make it clearer what the registration is for in client code. Changed.
Keith Miller
Comment 47 2017-05-12 17:48:43 PDT
Created attachment 309977 [details] Patch for landing
Keith Miller
Comment 48 2017-05-12 17:49:54 PDT
Created attachment 309980 [details] Patch for landing
WebKit Commit Bot
Comment 49 2017-05-12 18:30:17 PDT
Comment on attachment 309980 [details] Patch for landing Clearing flags on attachment: 309980 Committed r216808: <http://trac.webkit.org/changeset/216808>
WebKit Commit Bot
Comment 50 2017-05-12 18:30:20 PDT
All reviewed patches have been landed. Closing bug.
Filip Pizlo
Comment 51 2017-05-13 09:31:33 PDT
(In reply to WebKit Commit Bot from comment #49) > Comment on attachment 309980 [details] > Patch for landing > > Clearing flags on attachment: 309980 > > Committed r216808: <http://trac.webkit.org/changeset/216808> Wooohooo!
Yusuke Suzuki
Comment 52 2017-05-13 11:50:03 PDT
(In reply to Filip Pizlo from comment #51) > (In reply to WebKit Commit Bot from comment #49) > > Comment on attachment 309980 [details] > > Patch for landing > > > > Clearing flags on attachment: 309980 > > > > Committed r216808: <http://trac.webkit.org/changeset/216808> > > Wooohooo! One question: Is it OK to execute the message in a different thread? When using sendMessageUsingMach(), we execute the message handler in the sender thread instead of the target thread. It may change the behavior of TLS in the message handler. And if the above thing is OK, I think we can make ThreadMessage more portable... We can just implement ThreadMessage with Thread::suspend(), Thread::getRegisters(), Thread::setRegisters() (It can be implemented easily), and Thread::resume(). If we do so, we can implement ThreadMessage in Windows, which does not have signals.
WebKit Commit Bot
Comment 53 2017-05-13 13:30:51 PDT
Re-opened since this is blocked by bug 172075
Simon Fraser (smfr)
Comment 54 2017-05-13 13:31:47 PDT
This caused lldb to hang when debugging: rdar://problem/32178892
Note You need to log in before you can comment on or make changes to this bug.