-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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 random crash on app quit #11125
Fix random crash on app quit #11125
Conversation
704550f
to
7ddf1ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few inline comments on the implementation, but for the main point -- keeping the delegate alive after the context is destroyed -- I'm not sure I understand the implications well enough and defer to @zcbenz & @deepak1556 there
In the first place, who is still trying to use the delegate after the context is destroyed? Is this a question of the context needing to clean up better in its dtor?
@@ -34,7 +34,7 @@ class AtomCertVerifier : public net::CertVerifier { | |||
void SetVerifyProc(const VerifyProc& proc); | |||
|
|||
const VerifyProc verify_proc() const { return verify_proc_; } | |||
AtomCTDelegate* ct_delegate() const { return ct_delegate_; } | |||
AtomCTDelegate* ct_delegate() const { return ct_delegate_.get(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side issue, returning a raw pointer to a managed resource like this worries me a little... but in this case we have a cheap workaround, the only customer of this method is CertVerifierRequest
which is already a friend
, so we could move ct_delegate()
a few lines down here into the protected
section of the class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -25,7 +25,7 @@ struct VerifyRequestParams { | |||
|
|||
class AtomCertVerifier : public net::CertVerifier { | |||
public: | |||
explicit AtomCertVerifier(AtomCTDelegate* ct_delegate); | |||
explicit AtomCertVerifier(std::shared_ptr<AtomCTDelegate> ct_delegate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a const std::shared_ptr<AtomCTDelegate>&
here and in the .cc to avoid unnecessary temporaries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I can't answer that as I'm not very familiar with how chromium code works. In fact, I don't event know what the purpose of What I can say is that our application was randomly crashing with a similar stack as the one posted in #10051, and that ensuring It appears that whatever chromium object that calls |
7ddf1ba
to
832a950
Compare
Its possible for |
👍 I will adjust the PR |
46e736c
to
28345e2
Compare
@deepak1556 moved |
28345e2
to
d2d8ae7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just requires a few style changes 👍
@@ -138,6 +139,7 @@ URLRequestContextGetter::URLRequestContextGetter( | |||
in_memory_(in_memory), | |||
io_task_runner_(io_task_runner), | |||
file_task_runner_(file_task_runner), | |||
ct_delegate_(new RequireCTDelegate), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates the delegate on the UI thread, we should move the initialization into GetURLRequestContext
method below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -280,8 +282,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { | |||
|
|||
std::unique_ptr<net::TransportSecurityState> transport_security_state = | |||
base::WrapUnique(new net::TransportSecurityState); | |||
transport_security_state->SetRequireCTDelegate( | |||
delegate_->GetRequireCTDelegate()); | |||
transport_security_state->SetRequireCTDelegate(ct_delegate_.get()); | |||
storage_->set_transport_security_state(std::move(transport_security_state)); | |||
storage_->set_cert_verifier(delegate_->CreateCertVerifier()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its better to pass the ct_delegate
as a parameter of CreateCertVerifier
, can avoid having a GetRequireCTDelegate
getter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Move AtomCTDelegate to brightray as RequireCTDelegate and transfer ownership to brightray::URLRequestContextGetter. This fixes the wrong lifetime assumptions that result in AtomCTDelegate being used after free in some scenarios. Close #10051
d2d8ae7
to
a9a9e58
Compare
@deepak1556 done, addressed the requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Backported from the upstream #11125
Close #10051
@juturu can you confirm if this PR fixes the issue for you?