Fix Crash when shutting down after starting Assistant
This could lead to the following chain of events: - (Browser thread) Starts Assistant, and calls mojom method |ServiceController::Start()|. - (Browser thread) Stops Assistant, and calls mojom method |ServiceController::Stop()|. - (Mojom thread) ServiceController::Start() - Creates |AssistantManager| - Publishes it through the singleton |LibassistantV1Api|. - Informs browser thread through mojom method |StateObserver::OnStateChanged(started)|. - Here we get an interwoven sequence of events between the mojom thread and the browser thread: - (Mojom thread) ServiceController::Stop() - Informs browser thread through mojom method |StateObserver::OnStateChanged(stopped)|. - (Here we are 'interrupted' by the browser thread) - (Browser thread) StateObserver::OnStateChanged(started) calls AssistantManagerServiceImpl::PostInitAssistant() which accesses the |LibassistantV1Api| which is not null yet. - (Mojom thread) now destroys |LibassistantV1Api| and |AssistantManager|. - (Browser thread) dereferences the (now deleted) |AssistantManager| object and crashes. Bug: 1162136 Test: Compiled and deployed Change-Id: I86b30c76c544a926e46e7817540f17f0910da192 Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612402 Commit-Queue: Jeroen Dhollander <jeroendh@chromium.org> Reviewed-by:Xiaohui Chen <xiaohuic@chromium.org> Cr-Commit-Position: refs/heads/master@{#840883}
Showing
Please register or sign in to comment