Skip to content

Fix null-deref/double-dispose in StretchingOverscrollIndicator (#189589) - #189667

Merged
mbcorona merged 1 commit into
flutter:masterfrom
mbcorona:fix-stretch-overscroll-null-deref
Jul 21, 2026
Merged

Fix null-deref/double-dispose in StretchingOverscrollIndicator (#189589)#189667
mbcorona merged 1 commit into
flutter:masterfrom
mbcorona:fix-stretch-overscroll-null-deref

Conversation

@mbcorona

Copy link
Copy Markdown
Member

Description

Fixes a null pointer dereference crash in _StretchController.animate(). The whenComplete callback could execute after the controller was already disposed by a subsequent pull(), animate(), or dispose() call.

The fix captures the controller instance and guards cleanup to only execute if it's still active, preventing null dereference and double-dispose.

Fixed Issues

Fixes #189589

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 17, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Jul 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates _StretchController in overscroll_indicator.dart to prevent a crash when disposed during a stretch animation. It ensures that the animation's completion callback only cleans up state and disposes the controller if it remains the active controller, and sets _controller to null during disposal. A regression test has been added to verify this behavior. There are no review comments, and I have no feedback to provide.

@navaronbracke navaronbracke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with nit


testWidgets(
'StretchingOverscrollIndicator does not crash when disposed mid stretch animation',
// Regression test for https://github.com/flutter/flutter/issues/189589

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Put the comment above the test name or in the test body? Between the name and test function is a bit weird to read

@mbcorona
mbcorona added this pull request to the merge queue Jul 21, 2026
Merged via the queue into flutter:master with commit 801c2c6 Jul 21, 2026
19 of 20 checks passed
@mbcorona
mbcorona deleted the fix-stretch-overscroll-null-deref branch July 21, 2026 16:36
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 22, 2026
flutter/flutter@1ac2e82...2a2a79d

2026-07-22 21270878+elliette@users.noreply.github.com Clear cached directional focus history on a non-directional focus request  (flutter/flutter#187957)
2026-07-22 chris@bracken.jp ci: Include root pubspec.yaml in pub cache key (flutter/flutter#189826)
2026-07-22 6655696+guidezpl@users.noreply.github.com Remove codecov badge from README (flutter/flutter#189728)
2026-07-22 116356835+AbdeMohlbi@users.noreply.github.com Clean android engine/embedding tests (flutter/flutter#189276)
2026-07-22 50643541+Mairramer@users.noreply.github.com Add barrierBuilder support to showDialog and showGeneralDialog (flutter/flutter#187992)
2026-07-22 matt.boetger@gmail.com Fix Mockito dynamic agent loading warnings in Robolectric tests (flutter/flutter#189804)
2026-07-22 chris@bracken.jp [iOS] Remove dead RasterThreadMerger plumbing from platform views (flutter/flutter#189753)
2026-07-22 737941+loic-sharma@users.noreply.github.com Add OverlayPortal.overlayChildLayoutBuilder sample (flutter/flutter#188930)
2026-07-22 katelovett@google.com Automate recurring tasks via workflows - localizations (flutter/flutter#189750)
2026-07-21 chris@bracken.jp [iOS] Remove dead parameters and no-op overrides (flutter/flutter#189754)
2026-07-21 chris@bracken.jp [iOS] Inject DisplayLinkManager into FlutterViewController (flutter/flutter#189764)
2026-07-21 46920873+gabrimatic@users.noreply.github.com Support custom BoxBorder animation in BoxDecoration (flutter/flutter#186348)
2026-07-21 chingjun@google.com Rename CpuArch.x86_64 to CpuArch.x64 (flutter/flutter#189478)
2026-07-21 engine-flutter-autoroll@skia.org Roll Skia from 569534e9fa59 to 5e183e5aeac5 (3 revisions) (flutter/flutter#189795)
2026-07-21 engine-flutter-autoroll@skia.org Roll Dart SDK from 3b2f5ad7718d to 1e65011ee004 (4 revisions) (flutter/flutter#189791)
2026-07-21 jacksongardner@google.com Run delete-bot-branches.yaml on `pull_request_target` instead of `pull_request` so that we can access secrets. (flutter/flutter#189793)
2026-07-21 jmccandless@google.com Batch release directory correction (flutter/flutter#189738)
2026-07-21 brackenavaron@gmail.com [flutter_test][Test cross imports] Move TestWidgetsApp to flutter_test (flutter/flutter#189435)
2026-07-21 brunocorona.alcantar@gmail.com Fix null-deref/double-dispose in StretchingOverscrollIndicator (#189589) (flutter/flutter#189667)
2026-07-21 engine-flutter-autoroll@skia.org Roll Packages from 611899b to 8260a1e (10 revisions) (flutter/flutter#189782)
2026-07-21 chris@bracken.jp [iOS] Inject DisplayLinkManager into FlutterMetalLayer (flutter/flutter#189752)
2026-07-21 jason-simmons@users.noreply.github.com Derive the SkImage size used by ImageEncodingImpeller::ConvertDlImageToSkImage from the size of the underlying texture, not the size of the DlImage (flutter/flutter#189739)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Zubii12 pushed a commit to Zubii12/packages that referenced this pull request Jul 23, 2026
…r#12272)

flutter/flutter@1ac2e82...2a2a79d

2026-07-22 21270878+elliette@users.noreply.github.com Clear cached directional focus history on a non-directional focus request  (flutter/flutter#187957)
2026-07-22 chris@bracken.jp ci: Include root pubspec.yaml in pub cache key (flutter/flutter#189826)
2026-07-22 6655696+guidezpl@users.noreply.github.com Remove codecov badge from README (flutter/flutter#189728)
2026-07-22 116356835+AbdeMohlbi@users.noreply.github.com Clean android engine/embedding tests (flutter/flutter#189276)
2026-07-22 50643541+Mairramer@users.noreply.github.com Add barrierBuilder support to showDialog and showGeneralDialog (flutter/flutter#187992)
2026-07-22 matt.boetger@gmail.com Fix Mockito dynamic agent loading warnings in Robolectric tests (flutter/flutter#189804)
2026-07-22 chris@bracken.jp [iOS] Remove dead RasterThreadMerger plumbing from platform views (flutter/flutter#189753)
2026-07-22 737941+loic-sharma@users.noreply.github.com Add OverlayPortal.overlayChildLayoutBuilder sample (flutter/flutter#188930)
2026-07-22 katelovett@google.com Automate recurring tasks via workflows - localizations (flutter/flutter#189750)
2026-07-21 chris@bracken.jp [iOS] Remove dead parameters and no-op overrides (flutter/flutter#189754)
2026-07-21 chris@bracken.jp [iOS] Inject DisplayLinkManager into FlutterViewController (flutter/flutter#189764)
2026-07-21 46920873+gabrimatic@users.noreply.github.com Support custom BoxBorder animation in BoxDecoration (flutter/flutter#186348)
2026-07-21 chingjun@google.com Rename CpuArch.x86_64 to CpuArch.x64 (flutter/flutter#189478)
2026-07-21 engine-flutter-autoroll@skia.org Roll Skia from 569534e9fa59 to 5e183e5aeac5 (3 revisions) (flutter/flutter#189795)
2026-07-21 engine-flutter-autoroll@skia.org Roll Dart SDK from 3b2f5ad7718d to 1e65011ee004 (4 revisions) (flutter/flutter#189791)
2026-07-21 jacksongardner@google.com Run delete-bot-branches.yaml on `pull_request_target` instead of `pull_request` so that we can access secrets. (flutter/flutter#189793)
2026-07-21 jmccandless@google.com Batch release directory correction (flutter/flutter#189738)
2026-07-21 brackenavaron@gmail.com [flutter_test][Test cross imports] Move TestWidgetsApp to flutter_test (flutter/flutter#189435)
2026-07-21 brunocorona.alcantar@gmail.com Fix null-deref/double-dispose in StretchingOverscrollIndicator (#189589) (flutter/flutter#189667)
2026-07-21 engine-flutter-autoroll@skia.org Roll Packages from 611899b to 8260a1e (10 revisions) (flutter/flutter#189782)
2026-07-21 chris@bracken.jp [iOS] Inject DisplayLinkManager into FlutterMetalLayer (flutter/flutter#189752)
2026-07-21 jason-simmons@users.noreply.github.com Derive the SkImage size used by ImageEncodingImpeller::ConvertDlImageToSkImage from the size of the underlying texture, not the size of the DlImage (flutter/flutter#189739)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash in OverscrollIndicator

2 participants