Changeset 267206 in webkit


Ignore:
Timestamp:
Sep 17, 2020 1:21:33 PM (4 years ago)
Author:
ddkilzer@apple.com
Message:

WebKit::XPCServiceEventHandler block should call exit() on the main thread
<https://webkit.org/b/216594>
<rdar://problem/68053217>

Reviewed by Chris Dumez.

  • Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:

(WebKit::XPCServiceEventHandler):

  • Call exit() on the main thread. I chose dispatch_sync() here so that if other crashes occur on the main thread, we will know if this background thread is waiting to call exit() at the same time. Also, if a different background thread calls exit() in the future with this block running on the main thread, we'll know where the block came from since the XPC handler thread will be waiting for the dispatch_sync() to return (instead of having a mysterious block calling exit() on the main thread and not knowing where it came from).
  • Add logging (including simulated crash logs) when either of these exit() code paths is taken.
Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r267203 r267206  
     12020-09-17  David Kilzer  <ddkilzer@apple.com>
     2
     3        WebKit::XPCServiceEventHandler block should call exit() on the main thread
     4        <https://webkit.org/b/216594>
     5        <rdar://problem/68053217>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
     10        (WebKit::XPCServiceEventHandler):
     11        - Call exit() on the main thread. I chose dispatch_sync() here
     12          so that if other crashes occur on the main thread, we will
     13          know if this background thread is waiting to call exit() at
     14          the same time. Also, if a different background thread calls
     15          exit() in the future with this block running on the main
     16          thread, we'll know where the block came from since the XPC
     17          handler thread will be waiting for the dispatch_sync() to
     18          return (instead of having a mysterious block calling exit() on
     19          the main thread and not knowing where it came from).
     20        - Add logging (including simulated crash logs) when either of
     21          these exit() code paths is taken.
     22
    1232020-09-17  Hoa Dinh  <dvh@apple.com>
    224
  • trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm

    r265715 r267206  
    2727
    2828#import "HandleXPCEndpointMessages.h"
     29#import "Logging.h"
    2930#import "WKCrashReporter.h"
    3031#import "XPCServiceEntryPoint.h"
     
    4849        if (type == XPC_TYPE_ERROR) {
    4950            if (event == XPC_ERROR_CONNECTION_INVALID || event == XPC_ERROR_TERMINATION_IMMINENT) {
     51                RELEASE_LOG_FAULT(IPC, "Exiting: Received XPC event type: %s", event == XPC_ERROR_CONNECTION_INVALID ? "XPC_ERROR_CONNECTION_INVALID" : "XPC_ERROR_TERMINATION_IMMINENT");
    5052                // FIXME: Handle this case more gracefully.
    51                 exit(EXIT_FAILURE);
     53                dispatch_sync(dispatch_get_main_queue(), ^{
     54                    exit(EXIT_FAILURE);
     55                });
    5256            }
    5357        } else {
     
    7377                InitializerFunction initializerFunctionPtr = reinterpret_cast<InitializerFunction>(CFBundleGetFunctionPointerForName(webKitBundle, entryPointFunctionName));
    7478                if (!initializerFunctionPtr) {
    75                     NSLog(@"Unable to find entry point in WebKit.framework with name: %@", (__bridge NSString *)entryPointFunctionName);
    76                     exit(EXIT_FAILURE);
     79                    RELEASE_LOG_FAULT(IPC, "Exiting: Unable to find entry point in WebKit.framework with name: %s", [(__bridge NSString *)entryPointFunctionName UTF8String]);
     80                    dispatch_sync(dispatch_get_main_queue(), ^{
     81                        exit(EXIT_FAILURE);
     82                    });
    7783                }
    7884
Note: See TracChangeset for help on using the changeset viewer.