Skip to content

fix use-after-free of the EGL swapchain#9495

Merged
pixelflinger merged 1 commit intomainfrom
ma/swapchain-use-after-free
Dec 8, 2025
Merged

fix use-after-free of the EGL swapchain#9495
pixelflinger merged 1 commit intomainfrom
ma/swapchain-use-after-free

Conversation

@pixelflinger
Copy link
Collaborator

PlatformEGLAndroid holds onto the current swapchain in order to use it when beginFrame is called. Usually the swapchain is set just before beginFrame is called. However, that's not the case for standalone views. These are independent of the swapchain and doing "swapchain stuff" for them is nonsensical.

So make sure that:

  1. PlatfromEGLAndroid doesn't hold onto a dangling pointer when the swapchain is destroyed. And add proper null checks.
  2. Don't do the "swapchain stuff" when beginFrame is called in the context of a standalone view. We now reserve frameID 0 for that purpose (meaning the frameid is non sensical for these).

We're currently relying on frameID to not wrap-around. At 120 fps, that's about 1 year. This will be addressed in a later PR.

FIXES=[462827028, 461399487]

PlatformEGLAndroid holds onto the current swapchain in order to use
it when beginFrame is called. Usually the swapchain is set just before
beginFrame is called. However, that's not the case for standalone
views. These are independent of the swapchain and doing "swapchain
stuff" for them is nonsensical.

So make sure that:

1. PlatfromEGLAndroid doesn't hold onto a dangling pointer when the 
   swapchain is destroyed. And add proper null checks.
2. Don't do the "swapchain stuff" when beginFrame is called in the
   context of a standalone view.
   We now reserve frameID 0 for that purpose (meaning the frameid is
   non sensical for these).

We're currently relying on frameID to not wrap-around. At 120 fps, 
that's about 1 year. This will be addressed in a later PR.

FIXES=[462827028, 461399487]
@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label Dec 8, 2025
@pixelflinger pixelflinger merged commit ae3d98f into main Dec 8, 2025
18 checks passed
@pixelflinger pixelflinger deleted the ma/swapchain-use-after-free branch December 8, 2025 22:54
pixelflinger added a commit that referenced this pull request Dec 8, 2025
PlatformEGLAndroid holds onto the current swapchain in order to use
it when beginFrame is called. Usually the swapchain is set just before
beginFrame is called. However, that's not the case for standalone
views. These are independent of the swapchain and doing "swapchain
stuff" for them is nonsensical.

So make sure that:

1. PlatfromEGLAndroid doesn't hold onto a dangling pointer when the 
   swapchain is destroyed. And add proper null checks.
2. Don't do the "swapchain stuff" when beginFrame is called in the
   context of a standalone view.
   We now reserve frameID 0 for that purpose (meaning the frameid is
   non sensical for these).

We're currently relying on frameID to not wrap-around. At 120 fps, 
that's about 1 year. This will be addressed in a later PR.

FIXES=[462827028, 461399487]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Issue/PR does not affect clients

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants