Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 1829 #1830

Closed
wants to merge 11 commits into from
Closed

Conversation

fronneburg
Copy link
Contributor

Handle a crash in ResumeCtrlImpl cleanup if the class hasn't been fully initialized.

@@ -265,8 +265,10 @@ void ResumeCtrlImpl::OnSuspend() {
LOG4CXX_AUTO_TRACE(logger_);
StopSavePersistentDataTimer();
SaveAllApplications();
resumption_storage_->OnSuspend();
resumption_storage_->Persist();
if (resumption_storage_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resumption_storage cant be uninitialized if Init method was called.
It will be initialized either here: https://github.com/fronneburg/sdl_core/blob/58af36f00d9af10d18274251d750cf43b4b9e190/src/components/application_manager/src/resumption/resume_ctrl_impl.cc#L83
Or here https://github.com/fronneburg/sdl_core/blob/58af36f00d9af10d18274251d750cf43b4b9e190/src/components/application_manager/src/resumption/resume_ctrl_impl.cc#L107

But in case if Init method was not called, or other resumption method was called before Init called. this if won't resolve issue of null pointer access. Code will fail in StopSavePersistentDataTimer method in https://github.com/fronneburg/sdl_core/blob/58af36f00d9af10d18274251d750cf43b4b9e190/src/components/application_manager/src/resumption/resume_ctrl_impl.cc#L138

The only way to avoid null pointer access is to guarantee that resumption_storage_ is created before each ResumeCtrl method call. This can be done with DCHECKs or with creating stub of resumption_storage_ in ResumeCtrl constructor. Best solution is to create real resumption_storage_ in constructor, but it requires rework of SDL LifeCycle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ApplicationManagerImpl::Init, if the first call to InitDirectory fails, this causes LifeCycle::StartComponents to fail and the resumption_storage_ object in ResumeCtrlImpl will not be created. And then "main" calls LifeCycle::StopComponents, which calls ApplicationManagerImpl::Stop, which calls UnregisterAllApplications, which calls ResumeCtrlImpl::OnSuspend, with an uninitialized resumption_storage_ object.

Yes, it's true that there is another null pointer access, but I couldn't see that one being called unless proper init had taken place.

@JenkinsSDLOnCloud
Copy link

Can one of the admins verify this patch?

@jacobkeeler
Copy link
Contributor

@fronneburg Merge conflicts need to be resolved

@fronneburg
Copy link
Contributor Author

There seems to be a problem with protocol_handler_tm_test.cc that is unrelated to these changes. It happened on another, completely separate PR also.

@mkorniichuk
Copy link
Contributor

@fronneburg @jacobkeeler issues #1829 and #2428 are fixed in PR #2621. Current PR is not actual since there are not enough changes for current develop: ResumeCtrlImpl::OnIgnitionOff is called instead of ResumeCtrlImpl::OnSuspend in ApplicationManagerImpl::UnregisterAllApplications.

@iCollin
Copy link
Collaborator

iCollin commented Jun 6, 2020

These changes are no longer needed since #2621

@iCollin iCollin closed this Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants