-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Crash in AdblockCnameResolveHostClient #16062
Comments
@iefremov I think this crash might be happening after all because of the assumption we made in the end on that we could simply use the context stored in AdblockCnameResolveHostClient(
const ResponseCallback& next_callback,
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::shared_ptr<BraveRequestInfo> ctx) {
[...]
auto* web_contents = GetWebContents(
ctx->render_process_id, ctx->render_frame_id, ctx->frame_tree_node_id);
if (!web_contents) {
start_time_ = base::TimeTicks::Now();
this->OnComplete(net::ERR_FAILED, net::ResolveErrorInfo(), base::nullopt);
return;
}
content::BrowserContext* context = web_contents->GetBrowserContext();
[...]
network::mojom::NetworkContext* network_context =
content::BrowserContext::GetDefaultStoragePartition(context)
->GetNetworkContext();
[...]
} Instead, we now do this: AdblockCnameResolveHostClient(
const ResponseCallback& next_callback,
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::shared_ptr<BraveRequestInfo> ctx,
EngineFlags previous_result) {
[...]
network::mojom::NetworkContext* network_context =
content::BrowserContext::GetDefaultStoragePartition(
ctx->browser_context)
->GetNetworkContext();
[...]
} @iefremov It looks like there could be some race condition and blindly trusting |
yeah it seems this callback can outlive the browser context... Due to using shared_ptr and not canceling properly. So let's revert for now. Thanks @mariospr |
The ResponseCallback can outlive the BraveRequestInfo context and thus we can't trust it to retrieve the default storage partition. Instead, let's go back to the original code where we would attempt to retrieve the WebContents from the frame_tree_node_id, early returning if that was not possible. Resolves brave/brave-browser#16062
@iefremov Great. Just checked that all unit tests and all browser tests keep passing after that change, so here is the PR: |
@mariospr could you please uplift to beta? |
Uplift available in brave/brave-core#8934 |
https://brave.sp.backtrace.io/p/brave/debug?time=(relative-first-seen%2Cfloating%2Cweek)&filters=((callstack.functions%2Ccontains%2CAdblockCnameResolveHostClient)%2Cptype%3Dbrowser%2C_deleted%3D0)&debug=(%2215faebf%22,0,0)
The text was updated successfully, but these errors were encountered: