Skip to content

[stable] [flutter_tools] Fix crash in symbolize command on stream error - #191605

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-dcc19d432340a092ca9a3b4d666c14fecab20626
Aug 24, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-dcc19d432340a092ca9a3b4d666c14fecab20626

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Issue Link:

#191205

Impact Description:

When running flutter symbolize on an obfuscated stack trace, if the underlying process output stream completes or encounters an error while a Completer is already resolved, Symbolizer crashes unexpectedly with StateError: Bad state: Future already completed. This causes the CLI to exit abruptly during stack deobfuscation and crash report generation.

Changelog Description:

[flutter/191205] Prevent StateError: Bad state: Future already completed in Symbolizer by checking completer.isCompleted when handling stream errors and completions during stack symbolization.

Workaround:

Manually deobfuscate stack traces using standalone addr2line / atos / llvm-symbolizer tools.

Risk:

  • Low
  • Medium
  • High

Test Coverage:

  • Yes
  • No

Validation Steps:

  1. Generate an obfuscated stack trace using flutter build apk --obfuscate --split-debug-info=....
  2. Run flutter symbolize --debug-info=<symbols-file> -i <stacktrace.txt>.
  3. Verify that flutter symbolize processes the stack trace without throwing StateError: Bad state: Future already completed.

…er#191273)

Ensure the stream subscription in
`DwarfSymbolizationService.decodeWithUnits` sets `cancelOnError: true`.
When an error occurs in the stream, this automatically cancels the
subscription and prevents `onDone` from being invoked after `onError`,
avoiding a `StateError` from completing the completer a second time.

Fixes flutter#191205

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect between commits].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Aug 24, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 24, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@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 the DwarfSymbolizationService to cancel stream subscriptions on error and catch all Object types instead of just Exception during symbolization. It also adds a regression test to verify stream error handling. Feedback suggests utilizing a finally block to ensure output.close() is always executed, preventing potential resource leaks when stream errors occur.

Comment on lines 322 to 327
try {
await onDone.future;
await output.close();
} on Exception catch (err) {
} on Object catch (err) {
throwToolExit('Failed to symbolize stack trace:\n $err');
}

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.

medium

If onDone.future throws an error, await output.close() is skipped, which can lead to resource leaks (e.g., unclosed file descriptors or sockets) when stream errors occur. Consider using a finally block to ensure that output.close() is always called, regardless of whether the symbolization succeeded or failed.

    try {
      await onDone.future;
    } on Object catch (err) {
      throwToolExit('Failed to symbolize stack trace:\n $err');
    } finally {
      await output.close();
    }

@bkonyi bkonyi changed the title [CP-stable][flutter_tools] Fix crash in symbolize command on stream error [stable] [flutter_tools] Fix crash in symbolize command on stream error Aug 24, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 24, 2026
@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 24, 2026
@auto-submit
auto-submit Bot merged commit bb693d7 into flutter:flutter-3.47-candidate.0 Aug 24, 2026
10 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-stable-dcc19d432340a092ca9a3b4d666c14fecab20626 branch August 24, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants