Bug 172775

Summary: Use dispatch queues for mach exceptions
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: New BugsAssignee: Keith Miller <keith_miller>
Status: REOPENED    
Severity: Normal CC: benjamin, buildbot, cdumez, cmarcelo, commit-queue, dbates, ggaren, mark.lam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 172785    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing
none
Patch for landing commit-queue: commit-queue-

Keith Miller
Reported 2017-05-31 13:58:15 PDT
Use dispatch queues for mach exceptions
Attachments
Patch (5.05 KB, patch)
2017-05-31 14:15 PDT, Keith Miller
no flags
Patch (5.05 KB, patch)
2017-05-31 14:31 PDT, Keith Miller
no flags
Patch for landing (5.09 KB, patch)
2017-05-31 14:53 PDT, Keith Miller
no flags
Patch for landing (7.17 KB, patch)
2017-06-01 10:22 PDT, Keith Miller
commit-queue: commit-queue-
Keith Miller
Comment 1 2017-05-31 14:15:16 PDT
Keith Miller
Comment 2 2017-05-31 14:20:27 PDT
*** Bug 172003 has been marked as a duplicate of this bug. ***
Mark Lam
Comment 3 2017-05-31 14:23:20 PDT
Comment on attachment 311631 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=311631&action=review > Source/WTF/wtf/threads/Signals.cpp:84 > + // It's not clear that this needs to be the high priority queue but it should be rare and it might be > + // handling exceptions from high priority threads. Anyway, our handlers should be very fast anyway so it's > + // probably not the end of the world if we handle a low priority exception on a high priority queue. I think it should be high priority because this is the mechanism for interrupting the main thread. Otherwise, it may never interrupt the main thread if the main thread has a higher priority. > Source/WTF/wtf/threads/Signals.cpp:111 > + // We should never cancel our handler since it's a perminant thing. typo: /perminant/permanent/
Keith Miller
Comment 4 2017-05-31 14:27:11 PDT
Comment on attachment 311631 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=311631&action=review >> Source/WTF/wtf/threads/Signals.cpp:84 >> + // probably not the end of the world if we handle a low priority exception on a high priority queue. > > I think it should be high priority because this is the mechanism for interrupting the main thread. Otherwise, it may never interrupt the main thread if the main thread has a higher priority. I'm assuming you're talking about the thread messaging API. We don't interrupt the main thread with mach exceptions. We use mach_thread_suspend/resume. >> Source/WTF/wtf/threads/Signals.cpp:111 >> + // We should never cancel our handler since it's a perminant thing. > > typo: /perminant/permanent/ fixed.
Keith Miller
Comment 5 2017-05-31 14:31:56 PDT
Geoffrey Garen
Comment 6 2017-05-31 14:44:34 PDT
Comment on attachment 311634 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=311634&action=review r=me > Source/WTF/wtf/threads/Signals.cpp:87 > + RELEASE_ASSERT_WITH_MESSAGE(source, "We need to ensure our source was created"); dispatch_source_create doesn't use null as an error condition return value. So you should remove this assert. > Source/WTF/wtf/threads/Signals.cpp:89 > + dispatch_source_set_event_handler(source, ^{ You need to keep a pointer to your dispatch_source_t or it will appear to the leaks tool that it has leaked. I'd suggest capturing a pointer in your block: static dispatch_source_t s_source = source; It might also work just to do this: UNUSED_PARAM(source); > Source/WTF/wtf/threads/Signals.cpp:113 > + dispatch_source_set_cancel_handler(source, ^{ > + // We should never cancel our handler since it's a permanent thing. > + RELEASE_ASSERT_NOT_REACHED(); > + }); No need for this.
Keith Miller
Comment 7 2017-05-31 14:53:04 PDT
Created attachment 311640 [details] Patch for landing
Keith Miller
Comment 8 2017-05-31 14:54:51 PDT
Comment on attachment 311634 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=311634&action=review >> Source/WTF/wtf/threads/Signals.cpp:87 >> + RELEASE_ASSERT_WITH_MESSAGE(source, "We need to ensure our source was created"); > > dispatch_source_create doesn't use null as an error condition return value. So you should remove this assert. https://developer.apple.com/reference/dispatch/1385630-dispatch_source_create seems to disagree with you: Return Value A new dispatch source object or NULL if the dispatch source could not be created. >> Source/WTF/wtf/threads/Signals.cpp:89 >> + dispatch_source_set_event_handler(source, ^{ > > You need to keep a pointer to your dispatch_source_t or it will appear to the leaks tool that it has leaked. I'd suggest capturing a pointer in your block: > > static dispatch_source_t s_source = source; > > It might also work just to do this: > > UNUSED_PARAM(source); I'll try "UNUSED_PARAM(source);" >> Source/WTF/wtf/threads/Signals.cpp:113 >> + }); > > No need for this. OK, I removed it.
WebKit Commit Bot
Comment 9 2017-05-31 15:44:43 PDT
The commit-queue encountered the following flaky tests while processing attachment 311640 [details]: workers/wasm-hashset-many.html bug 172781 (author: sbarati@apple.com) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 10 2017-05-31 15:45:11 PDT
Comment on attachment 311640 [details] Patch for landing Clearing flags on attachment: 311640 Committed r217631: <http://trac.webkit.org/changeset/217631>
WebKit Commit Bot
Comment 11 2017-05-31 15:45:13 PDT
All reviewed patches have been landed. Closing bug.
WebKit Commit Bot
Comment 12 2017-05-31 16:22:05 PDT
Re-opened since this is blocked by bug 172785
Keith Miller
Comment 13 2017-06-01 10:22:17 PDT
Created attachment 311717 [details] Patch for landing
Keith Miller
Comment 14 2017-06-01 10:29:18 PDT
I think I figured out the issue. I think it was that we were calling set_state, while inside CFRunLoop which made things sad...
Keith Miller
Comment 15 2017-06-01 10:29:49 PDT
(In reply to Keith Miller from comment #14) > I think I figured out the issue. I think it was that we were calling > set_state, while inside CFRunLoop which made things sad... I just removed the set-state code since that was not used anyway.
WebKit Commit Bot
Comment 16 2017-06-01 10:31:43 PDT
Comment on attachment 311717 [details] Patch for landing Rejecting attachment 311717 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'apply-attachment', '--no-update', '--non-interactive', 311717, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: with fuzz 3. patching file Source/WTF/wtf/ThreadMessage.cpp Hunk #1 FAILED at 169. 1 out of 1 hunk FAILED -- saving rejects to file Source/WTF/wtf/ThreadMessage.cpp.rej patching file Source/WTF/wtf/threads/Signals.cpp Hunk #1 FAILED at 39. Hunk #2 FAILED at 73. Hunk #3 FAILED at 194. 3 out of 3 hunks FAILED -- saving rejects to file Source/WTF/wtf/threads/Signals.cpp.rej Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit Full output: http://webkit-queues.webkit.org/results/3854480
Note You need to log in before you can comment on or make changes to this bug.