gpu: Fix potential CurrentGL dangling pointer [chromium/src : main]

0 views
Skip to first unread message

Sunny Sachanandani (Gerrit)

unread,
Sep 6, 2023, 5:38:22 PMSep 6
to Zhenyao Mo, ozone-...@chromium.org

Attention is currently required from: Zhenyao Mo.

Sunny Sachanandani would like Zhenyao Mo to review this change.

View Change

gpu: Fix potential CurrentGL dangling pointer

There's a potential issue with GLContextEGL::ReleaseBackpressureFences
leaving the thread local CurrentGL pointer set if there was no previous
current context. This means that the pointer will be dangling when the
context is destroyed. This ordinarily doesn't happen with Ganesh/GL
since there's almost always a current GL context, but it's possible with
Graphite when SharedContext won't ever make its context current.

This CL also cleans up the code related to setting the thread local
CurrentGL pointer:

- GetGlContextForCurrentThread returns a reference to the thread local
CurrentGL pointer so it's renamed to ThreadLocalCurrentGL and is
not exposed via gl_bindings.h (see below).
- GetThreadLocalCurrentGL returns the CurrentGL pointer and is exported
in gl_bindings.h. It does not return a mutable reference though.
- SetCurrentGL sets the thread local CurrentGL pointer so it's renamed
to SetThreadLocalCurrentGL to distinguish it from GetCurrentGL which
is an accessor on the GLContext class.

Bug: 1478112
Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
---
M ui/gl/gl_bindings.h
M ui/gl/gl_context.cc
M ui/gl/gl_context_egl.cc
M ui/gl/gl_gl_api_implementation.cc
M ui/gl/gl_gl_api_implementation.h
M ui/gl/gl_implementation.cc
6 files changed, 36 insertions(+), 25 deletions(-)


To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
Gerrit-Change-Number: 4846817
Gerrit-PatchSet: 3
Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
Gerrit-Attention: Zhenyao Mo <z...@chromium.org>

Sunny Sachanandani (Gerrit)

unread,
Sep 6, 2023, 5:38:29 PMSep 6
to ozone-...@chromium.org, Zhenyao Mo, chromium...@chromium.org

Attention is currently required from: Zhenyao Mo.

Patch set 3:Auto-Submit +1Commit-Queue +1

View Change

1 comment:

To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
Gerrit-Change-Number: 4846817
Gerrit-PatchSet: 3
Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
Gerrit-Attention: Zhenyao Mo <z...@chromium.org>
Gerrit-Comment-Date: Wed, 06 Sep 2023 21:38:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Sunny Sachanandani (Gerrit)

unread,
Sep 6, 2023, 5:40:23 PMSep 6
to ozone-...@chromium.org, Chromium LUCI CQ, Zhenyao Mo, chromium...@chromium.org

Attention is currently required from: Zhenyao Mo.

View Change

2 comments:

    • File ui/gl/gl_context_egl.cc:

      • Patch Set #3, Line 459:

            if (prev_current_context != this) {
        SetThreadLocalCurrentGL(prev_current_context
        ? prev_current_context->GetCurrentGL()
        : nullptr);
        }

        This is the main fix in this CL BTW.

    To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
    Gerrit-Change-Number: 4846817
    Gerrit-PatchSet: 3
    Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-Attention: Zhenyao Mo <z...@chromium.org>
    Gerrit-Comment-Date: Wed, 06 Sep 2023 21:40:14 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No

    Zhenyao Mo (Gerrit)

    unread,
    Sep 8, 2023, 7:39:56 PMSep 8
    to Sunny Sachanandani, ozone-...@chromium.org, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Sunny Sachanandani.

    Patch set 5:Code-Review +1

    View Change

    1 comment:

    • Patchset:

      • Patch Set #5:

        LGTM

        Thanks for clean up and fixing the dangling pointer!

    To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
    Gerrit-Change-Number: 4846817
    Gerrit-PatchSet: 5
    Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-Attention: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Comment-Date: Fri, 08 Sep 2023 23:39:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes

    Sunny Sachanandani (Gerrit)

    unread,
    Sep 8, 2023, 7:41:56 PMSep 8
    to ozone-...@chromium.org, Zhenyao Mo, Chromium LUCI CQ, chromium...@chromium.org

    Patch set 5:Auto-Submit +1Commit-Queue +2

    View Change

    2 comments:

      • Patch Set #3, Line 459:

            if (prev_current_context != this) {
        SetThreadLocalCurrentGL(prev_current_context
        ? prev_current_context->GetCurrentGL()
        : nullptr);
        }

        This is the main fix in this CL BTW.

      • Acknowledged

    To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
    Gerrit-Change-Number: 4846817
    Gerrit-PatchSet: 5
    Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-Comment-Date: Fri, 08 Sep 2023 23:41:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Sunny Sachanandani <sun...@chromium.org>

    Sunny Sachanandani (Gerrit)

    unread,
    Sep 8, 2023, 9:11:16 PMSep 8
    to ozone-...@chromium.org, Zhenyao Mo, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Sunny Sachanandani.

    Patch set 5:Commit-Queue +2

    View Change

      To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
      Gerrit-Change-Number: 4846817
      Gerrit-PatchSet: 5
      Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
      Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
      Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
      Gerrit-Attention: Sunny Sachanandani <sun...@chromium.org>
      Gerrit-Comment-Date: Sat, 09 Sep 2023 01:11:08 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes

      Chromium LUCI CQ (Gerrit)

      unread,
      Sep 8, 2023, 9:55:55 PMSep 8
      to Sunny Sachanandani, ozone-...@chromium.org, Zhenyao Mo, chromium...@chromium.org

      Chromium LUCI CQ submitted this change.

      View Change

      Approvals: Sunny Sachanandani: Send CL to CQ automatically after approval; Commit Zhenyao Mo: Looks good to me
      gpu: Fix potential CurrentGL dangling pointer

      There's a potential issue with GLContextEGL::ReleaseBackpressureFences
      leaving the thread local CurrentGL pointer set if there was no previous
      current context. This means that the pointer will be dangling when the
      context is destroyed. This ordinarily doesn't happen with Ganesh/GL
      since there's almost always a current GL context, but it's possible with
      Graphite when SharedContext won't ever make its context current.

      This CL also cleans up the code related to setting the thread local
      CurrentGL pointer:

      - GetGlContextForCurrentThread returns a reference to the thread local
      CurrentGL pointer so it's renamed to ThreadLocalCurrentGL and is
      not exposed via gl_bindings.h (see below).
      - GetThreadLocalCurrentGL returns the CurrentGL pointer and is exported
      in gl_bindings.h. It does not return a mutable reference though.
      - SetCurrentGL sets the thread local CurrentGL pointer so it's renamed
      to SetThreadLocalCurrentGL to distinguish it from GetCurrentGL which
      is an accessor on the GLContext class.

      Bug: 1478112
      Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
      Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4846817
      Reviewed-by: Zhenyao Mo <z...@chromium.org>
      Commit-Queue: Sunny Sachanandani <sun...@chromium.org>
      Auto-Submit: Sunny Sachanandani <sun...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1194415}
      ---
      M gpu/command_buffer/service/external_semaphore.cc

      M ui/gl/gl_bindings.h
      M ui/gl/gl_context.cc
      M ui/gl/gl_context_egl.cc
      M ui/gl/gl_gl_api_implementation.cc
      M ui/gl/gl_gl_api_implementation.h
      M ui/gl/gl_implementation.cc
      7 files changed, 39 insertions(+), 28 deletions(-)


      To view, visit change 4846817. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Idd489ba129b2a59f8fcf5dd4edf379c3e9fe05aa
      Gerrit-Change-Number: 4846817
      Gerrit-PatchSet: 6
      Gerrit-Owner: Sunny Sachanandani <sun...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Sunny Sachanandani <sun...@chromium.org>
      Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
      Reply all
      Reply to author
      Forward
      0 new messages