-
Notifications
You must be signed in to change notification settings - Fork 870
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
Don't pass async override_response_headers ptr #8619
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kkuehlz
force-pushed
the
adblock_csp_dont_pass_raw_ptr
branch
from
April 23, 2021 00:37
badf970
to
f977dae
Compare
I have tried all day to consistently repproduce this locally to no avail. I got it once with an asan build. It points to us using the raw pointer. So let's pass the scoped_refpointer itself which should keep it alive. We don't actually need the headers as a pointer after setting it in OnHeadersReceived_AdBlockCspWork() anyway. ==2285653==ERROR: AddressSanitizer: heap-use-after-free on address 0x61d001294be8 at pc 0x5580b69e17e9 bp 0x7ffdf4686370 sp 0x7ffdf4686368 READ of size 8 at 0x61d001294be8 thread T0 (brave) #0 0x5580b69e17e8 in operator-> base/memory/scoped_refptr.h:235:5 #1 0x5580b69e17e8 in brave::OnReceiveCspDirectives(base::RepeatingCallback<void ()> const&, std::__Cr::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders>*, base::Optional<std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char> > >) brave/browser/net/brave_ad_block_csp_network_delegate_helper.cc:52:5 #2 0x5580b69e3c72 in Invoke<void (*)(const base::RepeatingCallback<void ()> &, std::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders> *, base::Optional<std::string>), base::RepeatingCallback<void ()>, std::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders> *, base::Optional<std::string> > base/bind_internal.h:393:12 #3 0x5580b69e3c72 in MakeItSo<void (*)(const base::RepeatingCallback<void ()> &, std::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders> *, base::Optional<std::string>), base::RepeatingCallback<void ()>, std::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders> *, base::Optional<std::string> > base/bind_internal.h:637:12 #4 0x5580b69e3c72 in RunImpl<void (*)(const base::RepeatingCallback<void ()> &, std::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders> *, base::Optional<std::string>), std::tuple<base::RepeatingCallback<void ()>, std::shared_ptr<brave::BraveRequestInfo>, scoped_refptr<net::HttpResponseHeaders> *>, 0, 1, 2> base/bind_internal.h:710:12 Maybe Resolves brave/brave-browser#15445
kkuehlz
force-pushed
the
adblock_csp_dont_pass_raw_ptr
branch
from
April 23, 2021 00:39
f977dae
to
71e6d16
Compare
iefremov
approved these changes
Apr 23, 2021
yeah, thanks a lot @keur . I was actually thinking about a larger fix (we basically shouldn't pass any raw pointers to callbacks, because owning URLLoader can die at any moment), but this bandaid should definitely fix the crash. Please uplift once merged |
The failing test on Linux is related to multiple uphold contributions. Seems unrelated. |
kylehickinson
pushed a commit
that referenced
this pull request
Jan 4, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Don't pass async override_response_headers ptr
I have tried all day to consistently repproduce this locally to no avail. I got
it once with an asan build. It points to us using the raw pointer. So let's
pass the scoped_refpointer itself which should keep it alive.
We don't actually need the headers as a pointer after setting it in
OnHeadersReceived_AdBlockCspWork() anyway.
==2285653==ERROR: AddressSanitizer: heap-use-after-free on address
0x61d001294be8 at pc 0x5580b69e17e9 bp 0x7ffdf4686370 sp 0x7ffdf4686368 READ of
size 8 at 0x61d001294be8 thread T0 (brave) #0 0x5580b69e17e8 in operator->
base/memory/scoped_refptr.h:235:5 #1 0x5580b69e17e8 in
brave::OnReceiveCspDirectives(base::RepeatingCallback<void ()> const&,
std::__Cr::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders,
base::Optional<std::__Cr::basic_string<char, std::__Cr::char_traits,
std::__Cr::allocator > >)
brave/browser/net/brave_ad_block_csp_network_delegate_helper.cc:52:5 #2
0x5580b69e3c72 in Invoke<void ()(const base::RepeatingCallback<void ()> &,
std::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders *, base::Optionalstd::string),
base::RepeatingCallback<void ()>, std::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders , base::Optionalstd::string >
base/bind_internal.h:393:12 #3 0x5580b69e3c72 in MakeItSo<void ()(const
base::RepeatingCallback<void ()> &, std::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders *, base::Optionalstd::string),
base::RepeatingCallback<void ()>, std::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders , base::Optionalstd::string >
base/bind_internal.h:637:12 #4 0x5580b69e3c72 in RunImpl<void ()(const
base::RepeatingCallback<void ()> &, std::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders *, base::Optionalstd::string),
std::tuple<base::RepeatingCallback<void ()>,
std::shared_ptrbrave::BraveRequestInfo,
scoped_refptrnet::HttpResponseHeaders *>, 0, 1, 2>
base/bind_internal.h:710:12
Maybe Resolves brave/brave-browser#15445