[Side Panel] Fix dangling WebContents pointer in ReadingListPageHandler [chromium/src : main]

0 views
Skip to first unread message

Eshwar Stalin (Gerrit)

unread,
Apr 20, 2026, 6:22:13 PM (10 days ago) Apr 20
to Foromo Daniel Soromou, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Caroline Rising, Darryl James and Foromo Daniel Soromou

Eshwar Stalin added 1 comment

File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.h
Line 109, Patchset 3 (Latest): base::WeakPtr<content::WebContents> web_contents_;
Eshwar Stalin . unresolved

Member variables should never be WeakPtrs. That's really against recommended usage of WeakPtr. We should fix lifecycle issues instead of turning things into Weakptrs.

Open in Gerrit

Related details

Attention is currently required from:
  • Caroline Rising
  • Darryl James
  • Foromo Daniel Soromou
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
Gerrit-Change-Number: 7775987
Gerrit-PatchSet: 3
Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Attention: Caroline Rising <cori...@chromium.org>
Gerrit-Attention: Darryl James <dlj...@chromium.org>
Gerrit-Attention: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Comment-Date: Mon, 20 Apr 2026 22:22:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Foromo Daniel Soromou (Gerrit)

unread,
Apr 20, 2026, 9:27:31 PM (10 days ago) Apr 20
to Eshwar Stalin, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Caroline Rising, Darryl James and Eshwar Stalin

Foromo Daniel Soromou added 1 comment

File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.h
Line 109, Patchset 3: base::WeakPtr<content::WebContents> web_contents_;
Eshwar Stalin . unresolved

Member variables should never be WeakPtrs. That's really against recommended usage of WeakPtr. We should fix lifecycle issues instead of turning things into Weakptrs.

Foromo Daniel Soromou

Ok great, Got it.

The main issue currently is that `ReadingListModel` outlives the `webui->WebContents()`, and synchronous model updates can fire while the browser/tab is shutting down.

I think alternatively to using a WeakPtr, stop observing the `ReadingListModel` when the WebContents is destroyed should address this.

WDYT?

Open in Gerrit

Related details

Attention is currently required from:
  • Caroline Rising
  • Darryl James
  • Eshwar Stalin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
Gerrit-Change-Number: 7775987
Gerrit-PatchSet: 4
Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Attention: Caroline Rising <cori...@chromium.org>
Gerrit-Attention: Eshwar Stalin <est...@chromium.org>
Gerrit-Attention: Darryl James <dlj...@chromium.org>
Gerrit-Comment-Date: Tue, 21 Apr 2026 01:27:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Eshwar Stalin <est...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Eshwar Stalin (Gerrit)

unread,
Apr 20, 2026, 9:30:35 PM (10 days ago) Apr 20
to Foromo Daniel Soromou, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Caroline Rising, Darryl James and Foromo Daniel Soromou

Eshwar Stalin added 1 comment

File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.h
Line 109, Patchset 3: base::WeakPtr<content::WebContents> web_contents_;
Eshwar Stalin . unresolved

Member variables should never be WeakPtrs. That's really against recommended usage of WeakPtr. We should fix lifecycle issues instead of turning things into Weakptrs.

Foromo Daniel Soromou

Ok great, Got it.

The main issue currently is that `ReadingListModel` outlives the `webui->WebContents()`, and synchronous model updates can fire while the browser/tab is shutting down.

I think alternatively to using a WeakPtr, stop observing the `ReadingListModel` when the WebContents is destroyed should address this.

WDYT?

Eshwar Stalin

Yeah that's the correct way to fix this.

Open in Gerrit

Related details

Attention is currently required from:
  • Caroline Rising
  • Darryl James
  • Foromo Daniel Soromou
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
Gerrit-Change-Number: 7775987
Gerrit-PatchSet: 4
Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Attention: Caroline Rising <cori...@chromium.org>
Gerrit-Attention: Darryl James <dlj...@chromium.org>
Gerrit-Attention: Foromo Daniel Soromou <koreta...@chromium.org>
Gerrit-Comment-Date: Tue, 21 Apr 2026 01:30:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Eshwar Stalin <est...@chromium.org>
Comment-In-Reply-To: Foromo Daniel Soromou <koreta...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Foromo Daniel Soromou (Gerrit)

unread,
Apr 20, 2026, 9:47:34 PM (10 days ago) Apr 20
to Eshwar Stalin, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Caroline Rising, Darryl James and Eshwar Stalin

Foromo Daniel Soromou added 1 comment

File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.h
Line 109, Patchset 3: base::WeakPtr<content::WebContents> web_contents_;
Eshwar Stalin . resolved

Member variables should never be WeakPtrs. That's really against recommended usage of WeakPtr. We should fix lifecycle issues instead of turning things into Weakptrs.

Foromo Daniel Soromou

Ok great, Got it.

The main issue currently is that `ReadingListModel` outlives the `webui->WebContents()`, and synchronous model updates can fire while the browser/tab is shutting down.

I think alternatively to using a WeakPtr, stop observing the `ReadingListModel` when the WebContents is destroyed should address this.

WDYT?

Eshwar Stalin

Yeah that's the correct way to fix this.

Foromo Daniel Soromou

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Caroline Rising
  • Darryl James
  • Eshwar Stalin
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
    Gerrit-Change-Number: 7775987
    Gerrit-PatchSet: 4
    Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
    Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
    Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
    Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
    Gerrit-Attention: Caroline Rising <cori...@chromium.org>
    Gerrit-Attention: Eshwar Stalin <est...@chromium.org>
    Gerrit-Attention: Darryl James <dlj...@chromium.org>
    Gerrit-Comment-Date: Tue, 21 Apr 2026 01:47:30 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Eshwar Stalin (Gerrit)

    unread,
    Apr 21, 2026, 12:19:57 AM (10 days ago) Apr 21
    to Foromo Daniel Soromou, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Caroline Rising, Darryl James and Foromo Daniel Soromou

    Eshwar Stalin added 2 comments

    Patchset-level comments
    File-level comment, Patchset 4 (Latest):
    Eshwar Stalin . resolved

    Mostly LGTM with one clarification.

    File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
    Line 426, Patchset 4 (Latest): CHECK(web_contents());
    Eshwar Stalin . unresolved

    I don't see anything that guarentees the web contents will always be valid when this is called. In other places where we CHECK(web_contents()) we ensure we unregister observing reading_list_model, but UpdateCurrentPageActionButton gets called in other places, so I think it might be safer to add nullptr checks for this?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Caroline Rising
    • Darryl James
    • Foromo Daniel Soromou
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
      Gerrit-Change-Number: 7775987
      Gerrit-PatchSet: 4
      Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
      Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
      Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
      Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Attention: Caroline Rising <cori...@chromium.org>
      Gerrit-Attention: Darryl James <dlj...@chromium.org>
      Gerrit-Attention: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Comment-Date: Tue, 21 Apr 2026 04:19:47 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Foromo Daniel Soromou (Gerrit)

      unread,
      Apr 21, 2026, 8:01:38 AM (10 days ago) Apr 21
      to Eshwar Stalin, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
      Attention needed from Caroline Rising, Darryl James and Eshwar Stalin

      Foromo Daniel Soromou added 1 comment

      File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
      Line 426, Patchset 4 (Latest): CHECK(web_contents());
      Eshwar Stalin . unresolved

      I don't see anything that guarentees the web contents will always be valid when this is called. In other places where we CHECK(web_contents()) we ensure we unregister observing reading_list_model, but UpdateCurrentPageActionButton gets called in other places, so I think it might be safer to add nullptr checks for this?

      Foromo Daniel Soromou

      The other place where it's called is in `SetActiveURL` which get invoke from `ReadingListUI::SetActiveTabURL`. `ReadingListUI` outlive it `web_contents` and `handler`, so I would be expecting that `web_contents` should be valid.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Caroline Rising
      • Darryl James
      • Eshwar Stalin
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
      Gerrit-Change-Number: 7775987
      Gerrit-PatchSet: 4
      Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
      Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
      Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
      Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
      Gerrit-Attention: Caroline Rising <cori...@chromium.org>
      Gerrit-Attention: Eshwar Stalin <est...@chromium.org>
      Gerrit-Attention: Darryl James <dlj...@chromium.org>
      Gerrit-Comment-Date: Tue, 21 Apr 2026 12:01:16 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Eshwar Stalin <est...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Eshwar Stalin (Gerrit)

      unread,
      Apr 21, 2026, 10:36:32 AM (9 days ago) Apr 21
      to Foromo Daniel Soromou, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
      Attention needed from Caroline Rising, Darryl James and Foromo Daniel Soromou

      Eshwar Stalin voted and added 1 comment

      Votes added by Eshwar Stalin

      Code-Review+1

      1 comment

      File chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
      Line 426, Patchset 4 (Latest): CHECK(web_contents());
      Eshwar Stalin . resolved

      I don't see anything that guarentees the web contents will always be valid when this is called. In other places where we CHECK(web_contents()) we ensure we unregister observing reading_list_model, but UpdateCurrentPageActionButton gets called in other places, so I think it might be safer to add nullptr checks for this?

      Foromo Daniel Soromou

      The other place where it's called is in `SetActiveURL` which get invoke from `ReadingListUI::SetActiveTabURL`. `ReadingListUI` outlive it `web_contents` and `handler`, so I would be expecting that `web_contents` should be valid.

      Eshwar Stalin

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Caroline Rising
      • Darryl James
      • Foromo Daniel Soromou
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
        Gerrit-Change-Number: 7775987
        Gerrit-PatchSet: 4
        Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
        Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
        Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
        Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Attention: Caroline Rising <cori...@chromium.org>
        Gerrit-Attention: Darryl James <dlj...@chromium.org>
        Gerrit-Attention: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Comment-Date: Tue, 21 Apr 2026 14:36:26 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Foromo Daniel Soromou (Gerrit)

        unread,
        Apr 21, 2026, 11:01:34 AM (9 days ago) Apr 21
        to Eshwar Stalin, Darryl James, Caroline Rising, Chromium LUCI CQ, chromium...@chromium.org
        Attention needed from Caroline Rising and Darryl James

        Foromo Daniel Soromou voted Commit-Queue+2

        Commit-Queue+2
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Caroline Rising
        • Darryl James
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
        Gerrit-Change-Number: 7775987
        Gerrit-PatchSet: 4
        Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
        Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
        Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
        Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Attention: Caroline Rising <cori...@chromium.org>
        Gerrit-Attention: Darryl James <dlj...@chromium.org>
        Gerrit-Comment-Date: Tue, 21 Apr 2026 15:01:26 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        Apr 21, 2026, 11:04:49 AM (9 days ago) Apr 21
        to Foromo Daniel Soromou, Eshwar Stalin, Darryl James, Caroline Rising, chromium...@chromium.org

        Chromium LUCI CQ submitted the change

        Change information

        Commit message:
        [Side Panel] Fix dangling WebContents pointer in ReadingListPageHandler

        This patch resolves a dangling pointer issue in ReadingListPageHandler
        by replacing the `DanglingUntriaged` raw pointer to
        `content::WebContents` with a `base::WeakPtr<content::WebContents>`.

        Because `WebContents` can be destroyed before the
        `ReadingListPageHandler` (e.g., during teardown), accessing the dangling
        raw pointer could lead to Use-After-Free (UAF) bugs . Null checks have
        been added to safely return early in cases where `web_contents_` has
        already been invalidated.
        Bug: 490505884
        Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
        Reviewed-by: Eshwar Stalin <est...@chromium.org>
        Commit-Queue: Foromo Daniel Soromou <koreta...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1618202}
        Files:
        • M chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
        • M chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.h
        Change size: S
        Delta: 2 files changed, 24 insertions(+), 9 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Eshwar Stalin
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I411121440d26ee770a775eda6d564ea56a385dbf
        Gerrit-Change-Number: 7775987
        Gerrit-PatchSet: 5
        Gerrit-Owner: Foromo Daniel Soromou <koreta...@chromium.org>
        Gerrit-Reviewer: Caroline Rising <cori...@chromium.org>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
        Gerrit-Reviewer: Eshwar Stalin <est...@chromium.org>
        Gerrit-Reviewer: Foromo Daniel Soromou <koreta...@chromium.org>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages