Failing iOS release builds – Target aot_assembly_release failed: Exception: AOT snapshotter exited with code -11

Steps to Reproduce

Hi. Since updating to Flutter > 2.x.x & dart > 2.10.x we have been experiencing issues building our application in release mode for iOS. The build process constantly fails on gen_snapshot_armrv7 when the Dart snapshot generator is running.
Note that the problem only occurs when building for release, debug mode works fine.

Command we use to build in release mode:

flutter build ios --release -t lib/main/main.dart --flavor production --verbose

I’m not sure if this issue belongs in the Flutter project or is related to Dart itself, but let me know if I should file the issue elsewhere.

Logs

Logs

Command on which the build crashes:

~/flutter-sdk/flutter/bin/cache/artifacts/engine/ios-release/gen_snapshot_armv7 --deterministic --snapshot_kind=app-aot-assembly --assembly=~/.dart_tool/flutter_build/38fb175c28ae1bcd6616e87f2782ecae/armv7/snapshot_assembly.S --strip --no-sim-use-hardfp --no-use-integer-division ~/.dart_tool/flutter_build/38fb175c28ae1bcd6616e87f2782ecae/app.dill
 [+10856 ms] Dart snapshot generator failed with exit code -11

Checking what the underlying issue seem to be with lldb yields (running the above gen_snapshot_armv7):

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7ffeef3ffff8)
    frame #0: 0x00007fff20449d90 libsystem_malloc.dylib`_malloc_zone_malloc + 8
libsystem_malloc.dylib`_malloc_zone_malloc:
->  0x7fff20449d90 <+8>:  pushq  %%r13
    0x7fff20449d92 <+10>: pushq  %%r12
    0x7fff20449d94 <+12>: pushq  %%rbx
    0x7fff20449d95 <+13>: pushq  %%rax
Target 0: (gen_snapshot_armv7) stopped.

Running disassemble --frame in lldb yields:

libsystem_malloc.dylib`_malloc_zone_malloc:
    0x7fff20449d88 <+0>:   pushq  %%rbp
    0x7fff20449d89 <+1>:   movq   %%rsp, %%rbp
    0x7fff20449d8c <+4>:   pushq  %%r15
    0x7fff20449d8e <+6>:   pushq  %%r14
->  0x7fff20449d90 <+8>:   pushq  %%r13
    0x7fff20449d92 <+10>:  pushq  %%r12
    0x7fff20449d94 <+12>:  pushq  %%rbx
    0x7fff20449d95 <+13>:  pushq  %%rax
    0x7fff20449d96 <+14>:  movl   %%edx, %%r14d
    0x7fff20449d99 <+17>:  movq   %%rsi, %%r12
    0x7fff20449d9c <+20>:  movq   %%rdi, %%r15
    0x7fff20449d9f <+23>:  movb   0x688162c6(%%rip), %%r13b   ; malloc_tracing_enabled
    0x7fff20449da6 <+30>:  testb  %%r13b, %%r13b
    0x7fff20449da9 <+33>:  jne    0x7fff20449e29            ; <+161>
    0x7fff20449dab <+35>:  cmpl   $0x0, 0x688162be(%%rip)    ; malloc_medium_space_efficient_enabled + 1
    0x7fff20449db2 <+42>:  jne    0x7fff20449e43            ; <+187>
    0x7fff20449db8 <+48>:  movq   0x5feb6f09(%%rip), %%rax    ; (void *)0x00007fff88c45db8: vm_kernel_page_size
    0x7fff20449dbf <+55>:  movq   (%%rax), %%rax
    0x7fff20449dc2 <+58>:  movq   0x5feb6f17(%%rip), %%rcx    ; (void *)0x00007fff88c45dd0: vm_page_size
    0x7fff20449dc9 <+65>:  movq   (%%rcx), %%rcx
    0x7fff20449dcc <+68>:  cmpq   %%rcx, %%rax
    0x7fff20449dcf <+71>:  cmovaq %%rax, %%rcx
    0x7fff20449dd3 <+75>:  addq   %%rcx, %%rcx
    0x7fff20449dd6 <+78>:  addq   %%r12, %%rcx
    0x7fff20449dd9 <+81>:  jae    0x7fff20449df4            ; <+108>
    0x7fff20449ddb <+83>:  testb  $0x1, %%r14b
    0x7fff20449ddf <+87>:  je     0x7fff20449df0            ; <+104>
    0x7fff20449de1 <+89>:  movq   %%gs:0x8, %%rax
    0x7fff20449dea <+98>:  movl   $0xc, (%%rax)
    0x7fff20449df0 <+104>: xorl   %%ebx, %%ebx
    0x7fff20449df2 <+106>: jmp    0x7fff20449e17            ; <+143>
    0x7fff20449df4 <+108>: movq   %%r15, %%rdi
    0x7fff20449df7 <+111>: movq   %%r12, %%rsi
    0x7fff20449dfa <+114>: callq  *0x18(%%r15)
    0x7fff20449dfe <+118>: movq   %%rax, %%rbx
    0x7fff20449e01 <+121>: movq   0x68816258(%%rip), %%rax    ; malloc_logger
    0x7fff20449e08 <+128>: testq  %%rax, %%rax
    0x7fff20449e0b <+131>: jne    0x7fff20449e65            ; <+221>
    0x7fff20449e0d <+133>: testb  %%r13b, %%r13b
    0x7fff20449e10 <+136>: jne    0x7fff20449e4d            ; <+197>
    0x7fff20449e12 <+138>: testq  %%rbx, %%rbx
    0x7fff20449e15 <+141>: je     0x7fff20449ddb            ; <+83>
    0x7fff20449e17 <+143>: movq   %%rbx, %%rax
    0x7fff20449e1a <+146>: addq   $0x8, %%rsp
    0x7fff20449e1e <+150>: popq   %%rbx
    0x7fff20449e1f <+151>: popq   %%r12
    0x7fff20449e21 <+153>: popq   %%r13
    0x7fff20449e23 <+155>: popq   %%r14
    0x7fff20449e25 <+157>: popq   %%r15
    0x7fff20449e27 <+159>: popq   %%rbp
    0x7fff20449e28 <+160>: retq
    0x7fff20449e29 <+161>: movl   $0x33010005, %%edi         ; imm = 0x33010005
    0x7fff20449e2e <+166>: movq   %%r15, %%rsi
    0x7fff20449e31 <+169>: movq   %%r12, %%rdx
    0x7fff20449e34 <+172>: xorl   %%ecx, %%ecx
    0x7fff20449e36 <+174>: xorl   %%r8d, %%r8d
    0x7fff20449e39 <+177>: callq  0x7fff20451e86            ; symbol stub for: kdebug_trace
    0x7fff20449e3e <+182>: jmp    0x7fff20449dab            ; <+35>
    0x7fff20449e43 <+187>: callq  0x7fff20451b10            ; internal_check
    0x7fff20449e48 <+192>: jmp    0x7fff20449db8            ; <+48>
    0x7fff20449e4d <+197>: movl   $0x33010006, %%edi         ; imm = 0x33010006
    0x7fff20449e52 <+202>: movq   %%r15, %%rsi
    0x7fff20449e55 <+205>: movq   %%r12, %%rdx
    0x7fff20449e58 <+208>: movq   %%rbx, %%rcx
    0x7fff20449e5b <+211>: xorl   %%r8d, %%r8d
    0x7fff20449e5e <+214>: callq  0x7fff20451e86            ; symbol stub for: kdebug_trace
    0x7fff20449e63 <+219>: jmp    0x7fff20449e12            ; <+138>
    0x7fff20449e65 <+221>: movl   $0xa, %%edi
    0x7fff20449e6a <+226>: movq   %%r15, %%rsi
    0x7fff20449e6d <+229>: movq   %%r12, %%rdx
    0x7fff20449e70 <+232>: xorl   %%ecx, %%ecx
    0x7fff20449e72 <+234>: movq   %%rbx, %%r8
    0x7fff20449e75 <+237>: xorl   %%r9d, %%r9d
    0x7fff20449e78 <+240>: callq  *%%rax
    0x7fff20449e7a <+242>: jmp    0x7fff20449e0d            ; <+133>

Output running flutter doctor -v

[✓] Flutter (Channel stable, 2.2.0, on macOS 11.2.3 20D91 darwin-x64, locale sv-SE)
    • Flutter version 2.2.0 at /Users/andreasostman/Desktop/swace/flutter-sdk/flutter
    • Framework revision b22742018b (4 days ago), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/andreasostman/Library/Android/sdk
    • Platform android-30, build-tools 29.0.2
    • ANDROID_HOME = /Users/andreasostman/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.56.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

1 thought on “Failing iOS release builds – Target aot_assembly_release failed: Exception: AOT snapshotter exited with code -11

Comments are closed.