Skip to content

Crash in [FlutterEngine destroyContext], Shell.reset() #115157

Closed as not planned

Description

@jacobsimionato

Cross posted from internal bug b/256086107

We're seeing a crash with about ~130 reports per day for Google customer Huggsy. There's no repro, but I wonder if there's enough detail in the stack trace to figure it out. The crash seems to happen during app termination (UIApplication _terminateWithStatus is in the stack trace), making it especially difficult to repro. I guess it's a memory management issue seeing as the crash is in objc_release?

Stack trace
Stack Trace:
0x0000000184acf680 ( libobjc.A.dylib + 0x00003680 ) objc_release
0x00000001d2e2e61c ( libsystem_blocks.dylib + 0x0000161c ) _call_dispose_helpers_excp
0x00000001d2e2e2b4 ( libsystem_blocks.dylib + 0x000012b4 ) _Block_release
0x00000001d2e2e61c ( libsystem_blocks.dylib + 0x0000161c ) _call_dispose_helpers_excp
0x00000001d2e2e2b4 ( libsystem_blocks.dylib + 0x000012b4 ) _Block_release
0x000000010516f07c ( Flutter - /opt/s/w/ir/cache/builder/src/out/ios_release/../../flutter/fml/platform/darwin/scoped_block.h:46 ) void std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, flutter::PlatformMessageHandlerIos::HandlerInfo>, void*>>>::destroy<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, flutter::PlatformMessageHandlerIos::HandlerInfo>>(std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, flutter::PlatformMessageHandlerIos::HandlerInfo>, void*>>&, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, flutter::PlatformMessageHandlerIos::HandlerInfo>*)
0x000000010516f02c ( Flutter - /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__hash_table:1602 ) std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, flutter::PlatformMessageHandlerIos::HandlerInfo>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, flutter::PlatformMessageHandlerIos::HandlerInfo>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, flutter::PlatformMessageHandlerIos::HandlerInfo>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, flutter::PlatformMessageHandlerIos::HandlerInfo>>>::~__hash_table()
0x000000010516e330 ( Flutter - /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__hash_table:1533 ) flutter::PlatformMessageHandlerIos::~PlatformMessageHandlerIos()
0x00000001054d41f8 ( Flutter - /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3346 ) flutter::Shell::~Shell()
0x0000000105141238 ( Flutter - /opt/s/w/ir/cache/builder/src/out/ios_release/../../flutter/shell/common/shell.cc:458 ) std::__1::unique_ptr<flutter::Shell, std::__1::default_delete<flutter::Shell>>::reset(flutter::Shell*)
0x000000010513ccd0 ( Flutter - /opt/s/w/ir/cache/builder/src/out/ios_release/../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm:428 ) -[FlutterEngine destroyContext]
0x00000001866bab40 ( CoreFoundation + 0x00034b40 ) __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
0x000000018675a0cc ( CoreFoundation + 0x000d40cc ) ___CFXRegistrationPost_block_invoke
0x000000018673eb74 ( CoreFoundation + 0x000b8b74 ) _CFXRegistrationPost
0x00000001866ce304 ( CoreFoundation + 0x00048304 ) _CFXNotificationPost
0x0000000185a734e8 ( Foundation + 0x000574e8 ) -[NSNotificationCenter postNotificationName:object:userInfo:]
0x000000018e264c44 ( UIKitCore + 0x00c6ac44 ) -[UIApplication _terminateWithStatus:]
0x000000018d86aad8 ( UIKitCore + 0x00270ad8 ) -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
0x000000018dc459e4 ( UIKitCore + 0x0064b9e4 ) -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:]
0x000000018e261360 ( UIKitCore + 0x00c67360 ) -[UIApplication workspaceShouldExit:withTransitionContext:]
0x000000019fca0384 ( FrontBoardServices + 0x0003b384 ) __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2
0x000000019fc6af6c ( FrontBoardServices + 0x00005f6c ) -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
0x000000019fca0328 ( FrontBoardServices + 0x0003b328 ) __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke
0x00000001923b67c4 ( libdispatch.dylib + 0x000647c4 ) _dispatch_client_callout
0x000000019238e404 ( libdispatch.dylib + 0x0003c404 ) _dispatch_block_invoke_direct$VARIANT$armv81
0x000000019fc74470 ( FrontBoardServices + 0x0000f470 ) __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
0x000000019fc740ac ( FrontBoardServices + 0x0000f0ac ) -[FBSSerialQueue _targetQueue_performNextIfPossible]
0x000000019fc76570 ( FrontBoardServices + 0x00011570 ) -[FBSSerialQueue _performNextFromRunLoopSource]
0x00000001867522b4 ( CoreFoundation + 0x000cc2b4 ) __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
0x000000018675dc14 ( CoreFoundation + 0x000d7c14 ) __CFRunLoopDoSource0
0x00000001866e7fa4 ( CoreFoundation + 0x00061fa4 ) __CFRunLoopDoSources0
0x00000001866fcfac ( CoreFoundation + 0x00076fac ) __CFRunLoopRun
0x0000000186701b78 ( CoreFoundation + 0x0007bb78 ) CFRunLoopRunSpecific
0x00000001c0a8d980 ( GraphicsServices + 0x00001980 ) GSEventRunModal
0x000000018d96f3c4 ( UIKitCore + 0x003753c4 ) -[UIApplication _run]
0x000000018d96f03c ( UIKitCore + 0x0037503c ) UIApplicationMain

Activity

  1. added
    platform-iosiOS applications specifically
    engineflutter/engine related. See also e: labels.
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    P1High-priority issues at the top of the work list
    c: fatal crashCrashes that terminate the process
    on Nov 11, 2022
  2. jacobsimionato commented on Nov 11, 2022

    @jacobsimionato
    ContributorAuthor

    I'll leave this unassigned to go through the regular triage process.

  3. jmagman commented on Nov 11, 2022

    @jmagman
    Member

    EXC_BAD_ACCESS / KERN_INVALID_ADDRESS

  4. removed
    P1High-priority issues at the top of the work list
    on Nov 14, 2022
  5. zanderso commented on Nov 14, 2022

    @zanderso
    Member

    Removing the priority so that we see this in triage. (@jacobsimionato In engine team triage, we assume that we've already triaged issues that have a priority assigned.)

  6. zanderso commented on Nov 14, 2022

    @zanderso
    Member

    @gaaclarke From triage, it looks like this is a crash during app shutdown, and we're wondering if it is due to a problem with the lifetime of message handler instances, which we're seeing in the backtrace. Could you take a look? It might be helpful to follow-up on the internal issue for more details.

  7. added
    P1High-priority issues at the top of the work list
    on Nov 14, 2022
  8. zanderso commented on Nov 14, 2022

    @zanderso
    Member

    Re-adding P3 since this is a bug we should look at, but the customer is not blocked.

  9. jacobsimionato commented on Nov 14, 2022

    @jacobsimionato
    ContributorAuthor

    @zanderso : Ahh that makes sense re priority - I will not add it in future for bugs that should go through regular triage. Thanks for the explainer!

  10. 5 remaining items

  11. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Jul 10, 2023
  12. cbracken commented on Sep 9, 2026

    @cbracken
    Member

    It looks likely that someone is manually calling [engine destroyContext] and then it gets automatically called again during teardown. If that's the case it's fixed by #192465.

  13. cbracken commented on Sep 9, 2026

    @cbracken
    Member

    The internal bug was closed as obsolete. Closing this as obsolete as well.

  14. github-actions commented on Sep 23, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  15. locked as resolved and limited conversation to collaborators on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: fatal crashCrashes that terminate the processcustomer: huggsy (g3)engineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions