Skip to content

Conversation

@jason-simmons
Copy link
Member

ContextVK had been using a thread-local counter to assign the value returned by GetHash. But CommandPoolRecyclerVK was using these values as keys in a process-wide global map.

If two engine instances using different task runner threads both created a ContextVK, then the thread-local counter could cause both contexts to share the same hash. So when CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools associated with the first context's hash, it will also incorrectly destroy the second context's pools.

Fixes #170141

ContextVK had been using a thread-local counter to assign the value returned
by GetHash.  But CommandPoolRecyclerVK was using these values as keys in a
process-wide global map.

If two engine instances using different task runner threads both created a
ContextVK, then the thread-local counter could cause both contexts to share
the same hash.  So when CommandPoolRecyclerVK::DestroyThreadLocalPools
destroys the pools associated with the first context's hash, it will also
incorrectly destroy the second context's pools.

Fixes flutter#170141
@jason-simmons jason-simmons requested a review from gaaclarke June 25, 2025 00:28
@github-actions github-actions bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 25, 2025
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with one minor request.

// You could make a context once per nanosecond for 584 years on one thread
// before this overflows.
return ++tls_context_count;
return ++context_count;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The google convention is to not use operators with atomic values.

Suggested change
return ++context_count;
return context_count.fetch_add(1);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jason-simmons jason-simmons added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 25, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jun 25, 2025
Merged via the queue into flutter:master with commit 89ba949 Jun 25, 2025
175 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 25, 2025
@jason-simmons jason-simmons added the cp: stable cherry pick this pull request to stable release candidate branch label Jun 26, 2025
flutteractionsbot pushed a commit to flutteractionsbot/flutter that referenced this pull request Jun 26, 2025
ContextVK had been using a thread-local counter to assign the value
returned by GetHash. But CommandPoolRecyclerVK was using these values as
keys in a process-wide global map.

If two engine instances using different task runner threads both created
a ContextVK, then the thread-local counter could cause both contexts to
share the same hash. So when
CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools
associated with the first context's hash, it will also incorrectly
destroy the second context's pools.

Fixes flutter#170141
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
ContextVK had been using a thread-local counter to assign the value
returned by GetHash. But CommandPoolRecyclerVK was using these values as
keys in a process-wide global map.

If two engine instances using different task runner threads both created
a ContextVK, then the thread-local counter could cause both contexts to
share the same hash. So when
CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools
associated with the first context's hash, it will also incorrectly
destroy the second context's pools.

Fixes flutter#170141
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp: stable cherry pick this pull request to stable release candidate branch e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persistent crash in FTL quick_actions Android tests

2 participants