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

Brave Ads crash when parsing country code from subdivision targeting code #12030

Closed
tmancey opened this issue Oct 7, 2020 · 4 comments · Fixed by brave/brave-core#6812
Closed

Comments

@tmancey
Copy link
Contributor

tmancey commented Oct 7, 2020

https://brave.sp.backtrace.io/p/brave/debug?time=all&filters=(_deleted%3D0%2C(callstack%2Cregex%2C%22(BatAds%7CAdsService%7CAdsImpl%7CConfirmationsImpl)%22)%2C(ver%2Cregex%2C%22(86.1%7C85.1%7C84.1%7C83.1)%22))&fingerprint=ac19dfa91b020a713c95f120f69321d8d29e9882182ec81c71ab50c8cbbc8ea8

[00] std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::basic_string
[01] ads::locale::GetCountryCode
[02] ads::SubdivisionTargetingFrequencyCap::DoesAdSupportSubdivisionTargetingCode
[03] ads::SubdivisionTargetingFrequencyCap::DoesRespectCap
[04] ads::SubdivisionTargetingFrequencyCap::ShouldExclude
[05] ads::AdsImpl::GetEligibleAds
[06] ads::AdsImpl::OnServeAdNotificationFromParentCategories
[07] ads::database::table::CreativeAdNotifications::OnGetCreativeAdNotifications(mojo::StructPtr<ads_database::mojom::DBCommandResponse>, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&, std::__1::function<void
[08] bat_ads::OnRunDBTransaction(std::__1::function<void
[09] bat_ads::mojom::BatAdsClient_RunDBTransaction_ForwardToCallback::Accept
[10] mojo::InterfaceEndpointClient::HandleValidatedMessage
[11] mojo::internal::MultiplexRouter::ProcessIncomingMessage
[12] mojo::internal::MultiplexRouter::Accept
[13] mojo::Connector::DispatchMessage
[14] mojo::Connector::ReadAllAvailableMessages
[15] base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl
[16] base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork
[17] base::MessagePumpDefault::Run
[18] base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run
[19] content::UtilityMain
[20] content::ContentMainRunnerImpl::Run
[21] service_manager::Main
[22] content::ContentMain
[23] ChromeMain
[24] main

@tmancey tmancey added crash priority/P2 A bad problem. We might uplift this to the next planned release. QA/Yes release-notes/exclude feature/ads OS/Desktop labels Oct 7, 2020
@tmancey tmancey self-assigned this Oct 8, 2020
@tmancey tmancey added priority/P3 The next thing for us to work on. It'll ride the trains. and removed priority/P2 A bad problem. We might uplift this to the next planned release. labels Oct 8, 2020
@tmancey
Copy link
Contributor Author

tmancey commented Oct 8, 2020

@jsecretan this issue occurs on startup if subdivision targeting is supported and we fail to fetch the region from the v5/getstate endpoint and then attempt to view a regional ad. Once we successfully fetch the region the crash no longer occurs.

This crash just takes down the ads service, which is restarted. All non regional ads will be delivered as expected.

@btlechowski
Copy link

Added QA/Blocked as I have some questions regarding the test plan.

@btlechowski
Copy link

The test plan from brave/brave-core#6812 has been updated. Removing QA/Blocked.

@btlechowski
Copy link

btlechowski commented Nov 6, 2020

Verification passed on

Brave 1.17.59 Chromium: 86.0.4240.183 (Official Build) dev (64-bit)
Revision 0b568b034b8f7994697cb341eeca5979b84151cc-refs/branch-heads/4240@{#1374}
OS Ubuntu 18.04 LTS

Verified test plan from brave/brave-core#6812

Verified status code was overridden to 304 for https://ads-serve.bravesoftware.com/v5/getstate

[3544:3544:1106/042828.916846:VERBOSE6:subdivision_targeting.cc(185)] URL Response:
  URL: https://ads-serve.bravesoftware.com/v5/getstate
  Response Status Code: 304
  Response: {"country":"US", "region":"CA"}
[3544:3544:1106/042828.918524:VERBOSE1:subdivision_targeting.cc(198)] Failed to fetch ads subdivision

Verified state targeted ads were not shown and there was not crash:

[3544:3544:1106/043112.546987:VERBOSE1:ads_impl.cc(763)] No purchase intent winning categories
[3544:3544:1106/043112.547063:VERBOSE1:ads_impl.cc(782)] No pages have been classified to serve targeted ads
[3544:3544:1106/043112.547118:VERBOSE1:ads_impl.cc(855)] Serving ad notification from untargeted category
[3544:3544:1106/043112.548159:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[3544:3544:1106/043112.548485:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[3544:3544:1106/043112.548817:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[3544:3544:1106/043112.548912:VERBOSE1:ads_impl.cc(918)] Ad notification not shown: No eligible ads found

Observed the log for crashes. There was no crash. The ads were not initialized again(expected).

Verified state targeted ads were shown when getstate override was turned off:

[4130:4130:1106/043828.468328:VERBOSE1:ads_impl.cc(763)] No purchase intent winning categories
[4130:4130:1106/043828.468378:VERBOSE1:ads_impl.cc(782)] No pages have been classified to serve targeted ads
[4130:4130:1106/043828.468436:VERBOSE1:ads_impl.cc(855)] Serving ad notification from untargeted category
[4130:4130:1106/043828.470307:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[4130:4130:1106/043828.471311:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[4130:4130:1106/043828.471382:VERBOSE2:eligible_ads_pacing_filter.cc(25)] 1 eligible ads before pacing
[4130:4130:1106/043828.471415:VERBOSE2:eligible_ads_pacing_filter.cc(40)] 1 eligible ads after pacing
[4130:4130:1106/043828.471495:VERBOSE2:eligible_ads_priority_filter.cc(81)] 1 eligible ads with a priority of 1
[4130:4130:1106/043828.471542:VERBOSE1:ads_impl.cc(900)] Found 1 eligible ads
[4130:4130:1106/043828.471734:VERBOSE1:ads_impl.cc(1149)] Ad notification shown:
  uuid: 54b449bc-8b1b-4b20-8397-8608062ab1b9
  creativeInstanceId: 89112634-8567-4dcb-9432-f81153c07ea6
  creativeSetId: afe51106-2c27-4aeb-87a6-cbf836f6da0b
  campaignId: 3055643b-e4de-48c6-8de4-7cec163373a4
  category: untargeted
  title: This is State Level Targeted Ad
  body: But still completely private!
  targetUrl: https://www.brave.com

Verified passed with

Brave	1.17.69 Chromium: 87.0.4280.60 (Official Build) (x86_64)
Revision	12697cfeb273d7de95cf9b18350d2c457f58224c-refs/branch-heads/4280@{#1352}
OS	macOS Version 10.14.6 (Build 18G6042)

Verified test plan from brave/brave-core#6812

Used Charles to re-write catalog and response status code for GET /v5/getstate

Confirmed override for response status code:

[8699:775:1116/112036.933157:VERBOSE1:subdivision_targeting.cc(171)] Fetch ads subdivision
[8699:775:1116/112036.933315:VERBOSE2:subdivision_targeting.cc(172)] GET /v5/getstate
[8699:775:1116/112036.933394:VERBOSE5:subdivision_targeting.cc(176)] URL Request:
  URL: https://ads-serve.bravesoftware.com/v5/getstate
  Method: BraveAdsUrlRequestMethod::GET
[8699:775:1116/112036.944914:VERBOSE6:ads_service_impl.cc(1099)] URL request started for /v5/getstate
[8699:775:1116/112036.945262:VERBOSE6:ads_service_impl.cc(1114)] URL request complete for /v5/getstate
[8699:775:1116/112036.945561:VERBOSE6:subdivision_targeting.cc(185)] URL Response:
  URL: https://ads-serve.bravesoftware.com/v5/getstate
  Response Status Code: 304
  Response: {"country":"US", "region":"PA"}
[8699:775:1116/112036.945646:VERBOSE1:subdivision_targeting.cc(198)] Failed to fetch ads subdivision

Verified state targeted ads were not shown and there was not crash:

[8888:775:1116/113814.182307:VERBOSE1:ads_impl.cc(763)] No purchase intent winning categories
[8888:775:1116/113814.182369:VERBOSE1:ads_impl.cc(782)] No pages have been classified to serve targeted ads
[8888:775:1116/113814.182405:VERBOSE1:ads_impl.cc(855)] Serving ad notification from untargeted category
[8888:775:1116/113814.183470:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[8888:775:1116/113814.183837:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[8888:775:1116/113814.183897:VERBOSE1:ads_impl.cc(918)] Ad notification not shown: No eligible ads found

Observed the log for crashes. There was no crash. The ads were not initialized again(expected).

Verified state targeted ads were shown when v5/getstate override was turned off:

[8940:775:1116/113952.475891:VERBOSE1:ads_impl.cc(763)] No purchase intent winning categories
[8940:775:1116/113952.475955:VERBOSE1:ads_impl.cc(782)] No pages have been classified to serve targeted ads
[8940:775:1116/113952.476006:VERBOSE1:ads_impl.cc(855)] Serving ad notification from untargeted category
[8940:775:1116/113952.477628:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[8940:775:1116/113952.478497:VERBOSE2:eligible_ads_pacing_filter.cc(25)] 1 eligible ads before pacing
[8940:775:1116/113952.478569:VERBOSE2:eligible_ads_pacing_filter.cc(40)] 1 eligible ads after pacing
[8940:775:1116/113952.478612:VERBOSE2:eligible_ads_priority_filter.cc(81)] 1 eligible ads with a priority of 1
[8940:775:1116/113952.478647:VERBOSE1:ads_impl.cc(900)] Found 1 eligible ads
[8940:775:1116/113952.478827:VERBOSE1:ads_impl.cc(1149)] Ad notification shown:
  uuid: ab71c9f3-681e-4b9c-80f4-e099cc361783
  creativeInstanceId: 89112634-8567-4dcb-9432-f81153c07ea6
  creativeSetId: afe51106-2c27-4aeb-87a6-cbf836f6da0b
  campaignId: 3055643b-e4de-48c6-8de4-7cec163373a4
  category: untargeted
  title: This is State Level Targeted to PA
  body: But still completely private!
  targetUrl: https://www.brave.com

Verification passed on

Brave 1.17.69 Chromium: 87.0.4280.60 (Official Build) (64-bit)
Revision 12697cfeb273d7de95cf9b18350d2c457f58224c-refs/branch-heads/4280@{#1352}
OS Windows 7 Service Pack 1 (Build 7601.24544)

Verified test plan from brave/brave-core#6812

Verified status code was overridden to 304 for https://ads-serve.bravesoftware.com/v5/getstate

[2028:14904:1118/040157.212:VERBOSE6:subdivision_targeting.cc(185)] URL Response:
  URL: https://ads-serve.bravesoftware.com/v5/getstate
  Response Status Code: 304
  Response: {"country":"US", "region":"CA"}
[2028:14904:1118/040157.213:VERBOSE1:subdivision_targeting.cc(198)] Failed to fetch ads subdivision

Verified state targeted ads were not shown and there was not crash:

[2028:14904:1118/040415.869:VERBOSE1:ads_impl.cc(855)] Serving ad notification from untargeted category
[2028:14904:1118/040415.870:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[2028:14904:1118/040415.870:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[2028:14904:1118/040415.870:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[2028:14904:1118/040415.870:VERBOSE1:ads_impl.cc(918)] Ad notification not shown: No eligible ads found

Observed the log for crashes. There was no crash. The ads were not initialized again(expected).

Verified state targeted ads were shown when getstate override was turned off:

[2028:14904:1118/040806.930:VERBOSE1:ads_impl.cc(763)] No purchase intent winning categories
[2028:14904:1118/040806.930:VERBOSE1:ads_impl.cc(782)] No pages have been classified to serve targeted ads
[2028:14904:1118/040806.930:VERBOSE1:ads_impl.cc(855)] Serving ad notification from untargeted category
[2028:14904:1118/040806.932:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[2028:14904:1118/040806.933:VERBOSE2:ads_impl.cc(991)] creativeSetId afe51106-2c27-4aeb-87a6-cbf836f6da0b excluded as not within the targeted subdivision
[2028:14904:1118/040806.933:VERBOSE2:eligible_ads_pacing_filter.cc(25)] 1 eligible ads before pacing
[2028:14904:1118/040806.933:VERBOSE2:eligible_ads_pacing_filter.cc(40)] 1 eligible ads after pacing
[2028:14904:1118/040806.933:VERBOSE2:eligible_ads_priority_filter.cc(81)] 1 eligible ads with a priority of 1
[2028:14904:1118/040806.933:VERBOSE1:ads_impl.cc(900)] Found 1 eligible ads
[2028:14904:1118/040806.933:VERBOSE1:ads_impl.cc(1149)] Ad notification shown:
  uuid: c0b07e60-1f5f-4aa7-a2a8-f501466953a8
  creativeInstanceId: 89112634-8567-4dcb-9432-f81153c07ea6
  creativeSetId: afe51106-2c27-4aeb-87a6-cbf836f6da0b
  campaignId: 3055643b-e4de-48c6-8de4-7cec163373a4
  category: untargeted
  title: This is State Level Targeted Ad
  body: But still completely private!
  targetUrl: https://www.brave.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants