New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 678556 link

Starred by 0 users

Issue metadata

Status: WontFix
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Using nullptr for RemoteSuggestionsScheduler causes brittle code

Project Member Reported by fhorschig@chromium.org, Jan 5 2017

Issue description

There have been three crashes recently where using the ContentSuggestionsService or the RemoteSuggestionsScheduler
caused a crash:
https://crbug.com/647920
https://crbug.com/648201
https://crbug.com/647920
https://crbug.com/678483

Everytime, the member content_suggestions_service_ or its 
member function remote_suggestions_scheduler() were accessed
and returned a nullptr which was supposed to be a object.

The ContentSuggestionsServiceFactory should always provide a
default/empty implementation for objects like the scheduler 
instead of just omitting their construction.
 
Okay, so this seems to be deeper rooted. The ContentSuggestionsServiceFactory sometimes provides a nullptr as response to: 

ContentSuggestionsServiceFactory::GetForProfile(
          ProfileManager::GetLastUsedProfile());

which resulted in this code:

// Can maybe be null in some cases? (Incognito profile?) crbug.com/647920
if (!content_suggestions_service) {
  return nullptr;
}

The referenced bug crbug.com/647920 introduced this fix but didn't resolve the underlying issue.
Before this bug can be fixed, it must be ensured that content_suggestions_service can not be nullptr.

Comment 2 by treib@chromium.org, Jan 25 2017

It is fairly common for factories for KeyedServices to return nullptr in some cases (incognito, mostly). I think we just have to deal with that.
Once you do have a non-null service, it still makes sense IMO to guarantee nothing else will be null, such as the scheduler.

Comment 3 by fi...@chromium.org, Feb 6 2017

Labels: -M-57 M-58 zine-triaged
Labels: -Restrict-View-Google -Pri-2 -M-58 Pri-3
Status: Available (was: Assigned)
Status: WontFix (was: Available)
As stated, this is rather common and can be changed if the behavior becomes more complex.

Sign in to add a comment