Skip to content

[macOS] Running a new Flutter app with Impeller on Coffee Lake CPU causes EXC_BAD_ACCESS: A bad access to memory terminated the process. #159278

@TecN01R

Description

@TecN01R

Steps to reproduce

I initially encountered this issue when trying to run the https://github.com/bdero/flutter-scene-example but have reduced the error to the simplest example possible

  1. Have a MacBook Pro 2019 (I assume any Mac with a Coffee Lake CPU would work) running the latest version of macOS (15.1.1 at the time of this writing)
  2. You can choose to use either stable or main branch
  3. Create a new Flutter project, using the empty or basic application.
  4. Enable native assets using flutter config --enable-native-assets
  5. Don't change anything and run flutter run -d macos --enable-impeller

I'll note that I ran into this issue and even took the liberty of wiping my Mac to factory settings and doing a fresh install and still encountered this issue. I am using VS Code. Executing the run command from the native Mac terminal results in the same error.

Expected results

App runs without issue

Actual results

App never launches. Instead the following is output into the terminal:

Error waiting for a debug connection: The log reader stopped unexpectedly, or never started.
Error launching application on macOS.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello World!'),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs The first time you run you'll get this
Launching lib/main.dart on macOS in debug mode...
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
Building macOS application...                                           
✓ Built build/macos/Build/Products/Debug/test_impeller.app
[IMPORTANT:flutter/shell/platform/embedder/embedder_surface_metal_impeller.mm(50)] Using the Impeller rendering backend (Metal).
Failed to foreground app; open returned 1
Error connecting to the service protocol: failed to connect to http://127.0.0.1:53162/fGPMZ3iR-r4=/ HttpException: Connection closed before full header was received, uri = http://127.0.0.1:53162/fGPMZ3iR-r4=/ws

Every subsequent run, even after a restart of the IDE or Mac will result in

Launching lib/main.dart on macOS in debug mode...
Building macOS application...                                           
✓ Built build/macos/Build/Products/Debug/test_impeller.app
[IMPORTANT:flutter/shell/platform/embedder/embedder_surface_metal_impeller.mm(50)] Using the Impeller rendering backend (Metal).
Error waiting for a debug connection: The log reader stopped unexpectedly, or never started.
Error launching application on macOS.

Running the command with verbose reveals some more information, but I'm not sure I see a smoking gun
https://pastebin.com/kaW5FHaH

Running via Xcode is perhaps where things get most interesting, as we receive an exception almost immediately while running that we can't get past

libsystem_platform.dylib`_platform_memmove$VARIANT$Haswell:
    0x7ff8062c84a0 <+0>:   pushq  %rbp
    0x7ff8062c84a1 <+1>:   movq   %rsp, %rbp
    0x7ff8062c84a4 <+4>:   movq   %rdi, %r11
    0x7ff8062c84a7 <+7>:   subq   %rsi, %r11
    0x7ff8062c84aa <+10>:  movq   %rdi, %rax
    0x7ff8062c84ad <+13>:  cmpq   %rdx, %r11
    0x7ff8062c84b0 <+16>:  jb     0x7ff8062c84cd            ; <+45>
    0x7ff8062c84b2 <+18>:  cmpq   $0x60, %rdx
    0x7ff8062c84b6 <+22>:  jbe    0x7ff8062c84e7            ; <+71>
    0x7ff8062c84b8 <+24>:  cmpq   $0x4000, %rdx             ; imm = 0x4000 
    0x7ff8062c84bf <+31>:  jb     0x7ff8062c8590            ; <+240>
    0x7ff8062c84c5 <+37>:  movq   %rdx, %rcx
    0x7ff8062c84c8 <+40>:  cld    
    0x7ff8062c84c9 <+41>:  rep    movsb	(%rsi), %es:(%rdi)
    0x7ff8062c84cb <+43>:  popq   %rbp
    0x7ff8062c84cc <+44>:  retq   
    0x7ff8062c84cd <+45>:  cmpq   %rdi, %rsi
    0x7ff8062c84d0 <+48>:  je     0x7ff8062c84cb            ; <+43>
    0x7ff8062c84d2 <+50>:  addq   %rdx, %rsi
    0x7ff8062c84d5 <+53>:  addq   %rdx, %rdi
    0x7ff8062c84d8 <+56>:  cmpq   $0x60, %rdx
    0x7ff8062c84dc <+60>:  jb     0x7ff8062c866e            ; <+462>
    0x7ff8062c84e2 <+66>:  jmp    0x7ff8062c8690            ; <+496>
    0x7ff8062c84e7 <+71>:  cmpq   $0x10, %rdx
    0x7ff8062c84eb <+75>:  jbe    0x7ff8062c8543            ; <+163>
    0x7ff8062c84ed <+77>:  vmovups -0x10(%rsi,%rdx), %xmm1
    0x7ff8062c84f3 <+83>:  subq   $0x20, %rdx
    0x7ff8062c84f7 <+87>:  jbe    0x7ff8062c8523            ; <+131>
    0x7ff8062c84f9 <+89>:  vmovups (%rsi), %ymm0
    0x7ff8062c84fd <+93>:  vmovups %ymm0, (%rdi)
    0x7ff8062c8501 <+97>:  addq   $0x20, %rsi
    0x7ff8062c8505 <+101>: addq   $0x20, %rdi
    0x7ff8062c8509 <+105>: subq   $0x20, %rdx
    0x7ff8062c850d <+109>: jb     0x7ff8062c8523            ; <+131>
    0x7ff8062c850f <+111>: vmovups (%rsi), %ymm0
    0x7ff8062c8513 <+115>: vmovups %ymm0, (%rdi)
    0x7ff8062c8517 <+119>: addq   $0x20, %rsi
    0x7ff8062c851b <+123>: addq   $0x20, %rdi
    0x7ff8062c851f <+127>: subq   $0x20, %rdx
    0x7ff8062c8523 <+131>: addq   $0x10, %rdx
    0x7ff8062c8527 <+135>: jle    0x7ff8062c8535            ; <+149>
    0x7ff8062c8529 <+137>: vmovups (%rsi), %xmm0
    0x7ff8062c852d <+141>: vmovups %xmm0, (%rdi)
    0x7ff8062c8531 <+145>: vxorps %xmm0, %xmm0, %xmm0
    0x7ff8062c8535 <+149>: vmovups %xmm1, (%rdi,%rdx)
    0x7ff8062c853a <+154>: vxorps %xmm1, %xmm1, %xmm1
    0x7ff8062c853e <+158>: popq   %rbp
    0x7ff8062c853f <+159>: vzeroupper 
    0x7ff8062c8542 <+162>: retq   
    0x7ff8062c8543 <+163>: subq   $0x8, %rdx
    0x7ff8062c8547 <+167>: jb     0x7ff8062c8559            ; <+185>
    0x7ff8062c8549 <+169>: movq   (%rsi), %rcx
    0x7ff8062c854c <+172>: movq   (%rsi,%rdx), %r8
    0x7ff8062c8550 <+176>: movq   %rcx, (%rdi)
    0x7ff8062c8553 <+179>: movq   %r8, (%rdi,%rdx)
    0x7ff8062c8557 <+183>: popq   %rbp
    0x7ff8062c8558 <+184>: retq   
    0x7ff8062c8559 <+185>: addq   $0x8, %rdx
    0x7ff8062c855d <+189>: je     0x7ff8062c8584            ; <+228>
    0x7ff8062c855f <+191>: xorq   %r8, %r8
    0x7ff8062c8562 <+194>: movb   (%rsi,%r8), %cl
->  0x7ff8062c8566 <+198>: movb   %cl, (%rdi,%r8)
    0x7ff8062c856a <+202>: subq   $0x1, %rdx
    0x7ff8062c856e <+206>: je     0x7ff8062c8584            ; <+228>
    0x7ff8062c8570 <+208>: movb   0x1(%rsi,%r8), %cl
    0x7ff8062c8575 <+213>: movb   %cl, 0x1(%rdi,%r8)
    0x7ff8062c857a <+218>: addq   $0x2, %r8
    0x7ff8062c857e <+222>: subq   $0x1, %rdx
    0x7ff8062c8582 <+226>: jne    0x7ff8062c8562            ; <+194>
    0x7ff8062c8584 <+228>: popq   %rbp
    0x7ff8062c8585 <+229>: retq   
    0x7ff8062c8586 <+230>: nopw   %cs:(%rax,%rax)
    0x7ff8062c8590 <+240>: vmovups (%rsi), %ymm0
    0x7ff8062c8594 <+244>: addq   $0x20, %rdi
    0x7ff8062c8598 <+248>: andq   $-0x20, %rdi
    0x7ff8062c859c <+252>: movq   %rdi, %rcx
    0x7ff8062c859f <+255>: subq   %rax, %rcx
    0x7ff8062c85a2 <+258>: addq   %rcx, %rsi
    0x7ff8062c85a5 <+261>: subq   %rcx, %rdx
    0x7ff8062c85a8 <+264>: vmovups (%rsi), %ymm1
    0x7ff8062c85ac <+268>: vmovups %ymm0, (%rax)
    0x7ff8062c85b0 <+272>: vxorps %ymm0, %ymm0, %ymm0
    0x7ff8062c85b4 <+276>: vmovups 0x20(%rsi), %ymm2
    0x7ff8062c85b9 <+281>: addq   $0x40, %rsi
    0x7ff8062c85bd <+285>: subq   $0x80, %rdx
    0x7ff8062c85c4 <+292>: jbe    0x7ff8062c8620            ; <+384>
    0x7ff8062c85c6 <+294>: testq  $0x1f, %rsi
    0x7ff8062c85cd <+301>: je     0x7ff8062c8600            ; <+352>
    0x7ff8062c85cf <+303>: vmovaps %ymm1, (%rdi)
    0x7ff8062c85d3 <+307>: vmovaps %ymm2, 0x20(%rdi)
    0x7ff8062c85d8 <+312>: addq   $0x40, %rdi
    0x7ff8062c85dc <+316>: vmovups (%rsi), %ymm1
    0x7ff8062c85e0 <+320>: vmovups 0x20(%rsi), %ymm2
    0x7ff8062c85e5 <+325>: addq   $0x40, %rsi
    0x7ff8062c85e9 <+329>: subq   $0x40, %rdx
    0x7ff8062c85ed <+333>: ja     0x7ff8062c85cf            ; <+303>
    0x7ff8062c85ef <+335>: jmp    0x7ff8062c8620            ; <+384>
    0x7ff8062c85f1 <+337>: nopw   %cs:(%rax,%rax)
    0x7ff8062c85fb <+347>: nopl   (%rax,%rax)
    0x7ff8062c8600 <+352>: vmovaps %ymm1, (%rdi)
    0x7ff8062c8604 <+356>: vmovaps %ymm2, 0x20(%rdi)
    0x7ff8062c8609 <+361>: addq   $0x40, %rdi
    0x7ff8062c860d <+365>: vmovaps (%rsi), %ymm1
    0x7ff8062c8611 <+369>: vmovaps 0x20(%rsi), %ymm2
    0x7ff8062c8616 <+374>: addq   $0x40, %rsi
    0x7ff8062c861a <+378>: subq   $0x40, %rdx
    0x7ff8062c861e <+382>: ja     0x7ff8062c8600            ; <+352>
    0x7ff8062c8620 <+384>: vmovups (%rsi,%rdx), %ymm3
    0x7ff8062c8625 <+389>: vmovups 0x20(%rsi,%rdx), %ymm4
    0x7ff8062c862b <+395>: vmovaps %ymm1, (%rdi)
    0x7ff8062c862f <+399>: vxorps %ymm1, %ymm1, %ymm1
    0x7ff8062c8633 <+403>: vmovaps %ymm2, 0x20(%rdi)
    0x7ff8062c8638 <+408>: vxorps %ymm2, %ymm2, %ymm2
    0x7ff8062c863c <+412>: vmovups %ymm3, 0x40(%rdi,%rdx)
    0x7ff8062c8642 <+418>: vxorps %ymm3, %ymm3, %ymm3
    0x7ff8062c8646 <+422>: vmovups %ymm4, 0x60(%rdi,%rdx)
    0x7ff8062c864c <+428>: vxorps %ymm4, %ymm4, %ymm4
    0x7ff8062c8650 <+432>: popq   %rbp
    0x7ff8062c8651 <+433>: vzeroupper 
    0x7ff8062c8654 <+436>: retq   
    0x7ff8062c8655 <+437>: nopw   %cs:(%rax,%rax)
    0x7ff8062c865f <+447>: nop    
    0x7ff8062c8660 <+448>: subq   $0x8, %rsi
    0x7ff8062c8664 <+452>: movq   (%rsi), %rcx
    0x7ff8062c8667 <+455>: subq   $0x8, %rdi
    0x7ff8062c866b <+459>: movq   %rcx, (%rdi)
    0x7ff8062c866e <+462>: subq   $0x8, %rdx
    0x7ff8062c8672 <+466>: jae    0x7ff8062c8660            ; <+448>
    0x7ff8062c8674 <+468>: addq   $0x8, %rdx
    0x7ff8062c8678 <+472>: je     0x7ff8062c868c            ; <+492>
    0x7ff8062c867a <+474>: subq   $0x1, %rsi
    0x7ff8062c867e <+478>: movb   (%rsi), %cl
    0x7ff8062c8680 <+480>: subq   $0x1, %rdi
    0x7ff8062c8684 <+484>: movb   %cl, (%rdi)
    0x7ff8062c8686 <+486>: subq   $0x1, %rdx
    0x7ff8062c868a <+490>: jne    0x7ff8062c867a            ; <+474>
    0x7ff8062c868c <+492>: popq   %rbp
    0x7ff8062c868d <+493>: retq   
    0x7ff8062c868e <+494>: nop    
    0x7ff8062c8690 <+496>: vmovups -0x20(%rsi), %ymm0
    0x7ff8062c8695 <+501>: movq   %rdi, %r11
    0x7ff8062c8698 <+504>: subq   $0x1, %rdi
    0x7ff8062c869c <+508>: andq   $-0x20, %rdi
    0x7ff8062c86a0 <+512>: movq   %r11, %rcx
    0x7ff8062c86a3 <+515>: subq   %rdi, %rcx
    0x7ff8062c86a6 <+518>: subq   %rcx, %rsi
    0x7ff8062c86a9 <+521>: subq   %rcx, %rdx
    0x7ff8062c86ac <+524>: vmovups -0x20(%rsi), %ymm1
    0x7ff8062c86b1 <+529>: vmovups %ymm0, -0x20(%r11)
    0x7ff8062c86b7 <+535>: vmovups -0x40(%rsi), %ymm2
    0x7ff8062c86bc <+540>: subq   $0x40, %rsi
    0x7ff8062c86c0 <+544>: vxorps %ymm0, %ymm0, %ymm0
    0x7ff8062c86c4 <+548>: subq   $0x80, %rdx
    0x7ff8062c86cb <+555>: jbe    0x7ff8062c8722            ; <+642>
    0x7ff8062c86cd <+557>: testq  $0x1f, %rsi
    0x7ff8062c86d4 <+564>: je     0x7ff8062c8700            ; <+608>
    0x7ff8062c86d6 <+566>: vmovaps %ymm1, -0x20(%rdi)
    0x7ff8062c86db <+571>: vmovaps %ymm2, -0x40(%rdi)
    0x7ff8062c86e0 <+576>: subq   $0x40, %rdi
    0x7ff8062c86e4 <+580>: vmovups -0x20(%rsi), %ymm1
    0x7ff8062c86e9 <+585>: vmovups -0x40(%rsi), %ymm2
    0x7ff8062c86ee <+590>: subq   $0x40, %rsi
    0x7ff8062c86f2 <+594>: subq   $0x40, %rdx
    0x7ff8062c86f6 <+598>: ja     0x7ff8062c86d6            ; <+566>
    0x7ff8062c86f8 <+600>: jmp    0x7ff8062c8722            ; <+642>
    0x7ff8062c86fa <+602>: nopw   (%rax,%rax)
    0x7ff8062c8700 <+608>: vmovaps %ymm1, -0x20(%rdi)
    0x7ff8062c8705 <+613>: vmovaps %ymm2, -0x40(%rdi)
    0x7ff8062c870a <+618>: subq   $0x40, %rdi
    0x7ff8062c870e <+622>: vmovaps -0x20(%rsi), %ymm1
    0x7ff8062c8713 <+627>: vmovaps -0x40(%rsi), %ymm2
    0x7ff8062c8718 <+632>: subq   $0x40, %rsi
    0x7ff8062c871c <+636>: subq   $0x40, %rdx
    0x7ff8062c8720 <+640>: ja     0x7ff8062c8700            ; <+608>
    0x7ff8062c8722 <+642>: subq   %rdx, %rsi
    0x7ff8062c8725 <+645>: vmovups -0x20(%rsi), %ymm3
    0x7ff8062c872a <+650>: vmovups -0x40(%rsi), %ymm4
    0x7ff8062c872f <+655>: vmovaps %ymm1, -0x20(%rdi)
    0x7ff8062c8734 <+660>: vxorps %ymm1, %ymm1, %ymm1
    0x7ff8062c8738 <+664>: vmovaps %ymm2, -0x40(%rdi)
    0x7ff8062c873d <+669>: vxorps %ymm2, %ymm2, %ymm2
    0x7ff8062c8741 <+673>: vmovups %ymm3, 0x20(%rax)
    0x7ff8062c8746 <+678>: vxorps %ymm3, %ymm3, %ymm3
    0x7ff8062c874a <+682>: vmovups %ymm4, (%rax)
    0x7ff8062c874e <+686>: vxorps %ymm4, %ymm4, %ymm4
    0x7ff8062c8752 <+690>: popq   %rbp
    0x7ff8062c8753 <+691>: vzeroupper 
    0x7ff8062c8756 <+694>: retq   

The error is here

0x7ff8062c8566 <+198>: movb   %cl, (%rdi,%r8)

with this exception

io.flutter.raster (9): EXC_BAD_ACCESS (code=1, address=0x0)
A bad access to memory terminated the process.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1.1 24B91 darwin-x64, locale en-US)
    • Flutter version 3.24.5 on channel stable at /Users/kpmcdole/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (8 days ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/kpmcdole/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915915-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915915-b509.11)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.1.1 24B91 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 131.0.6778.86

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: desktopRunning on desktopc: crashStack traces logged to the consolee: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.platform-macBuilding on or for macOS specificallyr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions