Manage job and process lifetimes in sandbox tracker thread
During process creation, a job tracker (JobTracker as before) or a process tracker (ProcessTracker) is created in the process launching thread. These are then posted to the tracking thread (TargetEventsThread) (before the job is associated with the thread). New control keys are provided for the tracking thread to receive these objects and take ownership. For jobs, they are stored in a job tracking list (jobs) and job notifications are used to determine if a job has finished. Now, when finished, the tracking is removed from the job tracking list and destroyed, freeing the related target policy. For processes, these are now stored in a process tracking list (processes) and a wait registered on the default thread pool for a duplicated copy of the process’s handle to signal process exit. The wait’s callback simply posts a message to the tracking thread indicating that the process is done. When a process is done, the process tracker is removed from the process tracking list and freed. The related target policy is freed. As there may be more than MAXIMUM_WAIT_OBJECTS(=64) children we use RegisterWaitForSingleObject and a lightweight callback to post back to the tracking thread. No manipulation of these lists is done outside of the tracking thread. Policies used to be destroyed in the BrokerServices dtor so this may move some crashes around, especially if there are many processes and shutdown is stalled by a busy host. child_process_ids can now be manipulated entirely within the tracking thread so does not need locking. The working of WaitForAllTargets() could be improved but is not addressed in this effort. The lock is no longer required. This CL prepares for chrome://sandbox on Windows by moving access to stored policy objects to a single thread. I have manually tested by simulating a job-free chrome. Notes for this CL https://docs.google.com/document/d/1_9lde2MOX96VxE6k7IYtQFb5Zwpom5ZLFhCsfI7xXIc/edit#heading=h.3jv39q2gpdkw Change-Id: I35d7970fc285d80bd6ea2143cdab7d82b42d57cd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743294 Commit-Queue: Alex Gough <ajgo@chromium.org> Reviewed-by:Will Harris <wfh@chromium.org> Cr-Commit-Position: refs/heads/master@{#695315}
Showing
This diff is collapsed.
Please register or sign in to comment