filip
February 24, 2025, 6:05pm
1
Apple seems to have made a change and Flutter debug builds will not build / will crash on iOS 18.4. (Release and profile builds are fine.)
opened 06:18AM - 24 Feb 25 UTC
platform-ios
tool
engine
t: hot reload
P1
### Steps to reproduce
1. Run flutter ios in debug mode with ios 18.4
2. Notice… the error ../../../flutter/third_party/dart/runtime/vm/virtual_memory_posix.cc: 428: error: mprotect failed: 13 (Permission denied)
3. The build will fail. === Crash occurred when compiling unknown function in unoptimized JIT mode in unknown pass
### Expected results
Fluter build should not fail when in debug mode.
### Actual results
Flutter build fails on ios in debug mode with version 18.4
### Code sample
This is related to the build and not the code.
### Screenshots or Video
<details open>
<summary>Screenshots / Video demonstration</summary>
[Upload media here]
</details>
### Logs
<details open><summary>Logs</summary>
```console
../../../flutter/third_party/dart/runtime/vm/virtual_memory_posix.cc: 428: error: mprotect failed: 13 (Permission denied)
version=3.7.0 (stable) (Wed Feb 5 04:53:58 2025 -0800) on "ios_arm64"
pid=726, thread=259, isolate_group=vm-isolate(0x11ea52800), isolate=vm-isolate(0x11ebe5800)
os=ios, arch=arm64, comp=no, sim=no
isolate_instructions=10f8ab5a0, vm_instructions=10f8ab5a0
fp=16eee4f50, sp=16eee4f30, pc=110302e84
pc 0x0000000110302e84 fp 0x000000016eee4f50 Dart_DumpNativeStackTrace+0x18
pc 0x000000010feb1428 fp 0x000000016eee4f70 dart::Assert::Fail(char const*, ...) const+0x30
pc 0x000000010ffac33c fp 0x000000016eee5420 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x82c
pc 0x0000000110039cb0 fp 0x000000016eee5a30 dart::StubCode::Init()+0x320
pc 0x000000010fefc4f4 fp 0x000000016eee64e0 dart::Dart::DartInit(Dart_InitializeParams const*)+0x2b18
pc 0x00000001102e9754 fp 0x000000016eee6960 Dart_Initialize+0x60
pc 0x000000010fe71e24 fp 0x000000016eee6f30 flutter::DartVM::Create(flutter::Settings const&, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>, std::_fl::shared_ptr<flutter::IsolateNameServer>)+0x1d64
pc 0x000000010fdcdf9c fp 0x000000016eee7690 flutter::Shell::Create(flutter::PlatformData const&, flutter::TaskRunners const&, flutter::Settings, std::_fl::function<std::_fl::unique_ptr<flutter::PlatformView, std::_fl::default_delete<flutter::PlatformView>> (flutter::Shell&)> const&, std::_fl::function<std::_fl::unique_ptr<flutter::Rasterizer, std::_fl::default_delete<flutter::Rasterizer>> (flutter::Shell&)> const&, bool)+0x310
pc 0x000000010f8ba564 fp 0x000000016eee8420 -[FlutterEngine createShell:libraryURI:initialRoute:]+0xa8c
pc 0x000000010f8ece64 fp 0x000000016eee8480 -[FlutterViewController sharedSetupWithProject:initialRoute:]+0x198
pc 0x000000010f8ecca4 fp 0x000000016eee84b0 -[FlutterViewController awakeFromNib]+0x6c
pc 0x000000018a580450 fp 0x000000016eee8980 <redacted>+0x6dc
pc 0x000000018a5ef55c fp 0x000000016eee89f0 <redacted>+0xec
pc 0x000000018a5ef368 fp 0x000000016eee8a20 <redacted>+0x50
pc 0x000000018a5eee68 fp 0x000000016eee8a80 <redacted>+0x8c
pc 0x000000018a48d180 fp 0x000000016eee8ac0 <redacted>+0xa8
pc 0x000000018a48d980 fp 0x000000016eee8cd0 <redacted>+0x338
pc 0x000000018a4cebd8 fp 0x000000016eee8d10 <redacted>+0x84
pc 0x000000018a3e11e4 fp 0x000000016eee8d60 _UIScenePerformActionsWithLifecycleActionMask+0x70
pc 0x000000018a3e32c0 fp 0x000000016eee8e20 <redacted>+0xfc
pc 0x000000018a3e2fb4 fp 0x000000016eee8e90 <redacted>+0xd4
pc 0x000000018a3e1cc8 fp 0x000000016eee8fa0 <redacted>+0x260
pc 0x000000018a3e19e8 fp 0x000000016eee9010 <redacted>+0xf4
pc 0x000000018a3e1594 fp 0x000000016eee9050 <redacted>+0x94
pc 0x000000018a28cc38 fp 0x000000016eee9150 <redacted>+0x2e0
pc 0x000000018a28c260 fp 0x000000016eee91c0 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion+0xe0
pc 0x000000018a3361d8 fp 0x000000016eee92c0 <redacted>+0x13c
pc 0x000000018a335f64 fp 0x000000016eee9410 <redacted>+0x268
pc 0x000000018a3358b0 fp 0x000000016eee9580 <redacted>+0xd0
pc 0x000000018a2e13ac fp 0x000000016eee9640 <redacted>+0xf4
pc 0x000000018a2e0ed4 fp 0x000000016eee9720 <redacted>+0x2fc
pc 0x000000018a2e0b6c fp 0x000000016eee97b0 <redacted>+0x120
pc 0x00000001a279330c fp 0x000000016eee98f0 <redacted>+0x120
pc 0x00000001a277f2d8 fp 0x000000016eee9920 <redacted>+0x44
pc 0x00000001a27998b8 fp 0x000000016eee99f0 <redacted>+0x1b4
pc 0x00000001a2798f2c fp 0x000000016eee9ab0 <redacted>+0x120
pc 0x00000001a2798c58 fp 0x000000016eee9af0 <redacted>+0xa8
pc 0x00000001a279913c fp 0x000000016eee9c40 <redacted>+0x1d8
pc 0x00000001051c5f80 fp 0x000000016eee9c50 _dispatch_client_callout+0x10
pc 0x00000001051b07fc fp 0x000000016eee9ca0 _dispatch_block_invoke_direct+0x128
pc 0x00000001a2795658 fp 0x000000016eee9cd0 <redacted>+0x34
pc 0x00000001a27955d8 fp 0x000000016eee9d60 <redacted>+0xf0
pc 0x00000001a27954b0 fp 0x000000016eee9d80 <redacted>+0x1c
pc 0x0000000187884dc8 fp 0x000000016eee9d90 <redacted>+0x1c
pc 0x0000000187884d5c fp 0x000000016eee9dc0 <redacted>+0xac
pc 0x0000000187883ae0 fp 0x000000016eee9e20 <redacted>+0xe8
pc 0x0000000187882d20 fp 0x000000016eeeab90 <redacted>+0x348
pc 0x00000001878a77f0 fp 0x000000016eeeac10 CFRunLoopRunSpecific+0x23c
pc 0x00000001d4afa190 fp 0x000000016eeeac70 GSEventRunModal+0xa8
pc 0x000000018a4ce158 fp 0x000000016eeeacf0 <redacted>+0x330
pc 0x000000018a4cc388 fp 0x000000016eeead80 UIApplicationMain+0x150
pc 0x000000018a927eb4 fp 0x000000016eeeadc0 <redacted>+0x265c
pc 0x0000000102b0d26c fp 0x000000016eeeae10 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ+0x78
pc 0x0000000102b0d1e4 fp 0x000000016eeeae40 $s6Runner11AppDelegateC5$mainyyFZ+0x2c
pc 0x0000000102b0d2e8 fp 0x000000016eeeae60 __debug_main_executable_dylib_entry_point+0x1c
pc 0x00000001aee53a58 fp 0x000000016eeeb4c0 <redacted>+0x174c
-- End of DumpStackTrace
=== Crash occurred when compiling unknown function in unoptimized JIT mode in unknown pass
=== Flow Graph not available```
</details>
### Flutter Doctor output
<details open><summary>Doctor output</summary>
```console
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.3.1 24D70 darwin-arm64, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.1)
[✓] VS Code (version 1.97.2)
[✓] Connected device (5 available)
! Error: Browsing on the local area network for Nick’s iPhone. Ensure the device is
unlocked and attached with a cable or associated with the same local area network as
this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
! Doctor found issues in 1 category.
```
</details>
More details (copypasting @mraleph ’s comment on that issue:
It seems that iOS 18.4 has finally closed a long existing loophole with get-task-allow
allowing to bypass code signing restrictions. The app itself can no longer write into its own executable memory and flip permission RX->RW and back. The is a special path built into kernel to allow debugserver
do these things (based on private entitlement). Some preliminary analysis of kernel changes available here .
What this means for us:
we need to go back and fallback to interpretation for development builds like we did in the early days of Flutter. That’s fairly straightforward - but we would need to tackle performance implications to the extent we can . (Another thing is dart:ffi
- we would need to write generic stubs for ABI marshalling which do not rely on JIT code generation.)
In the interim we need to warn people that they would not be able to develop on iOS 18.4 (release and profile builds are fine though) - so they should not update their phones if they want to use hot reload and stuff.
11 Likes
Thanks for posting a heads up, Filip!
I want to jump in and confirm that the Flutter team is aware of this issue and is working on a fix. I probably can’t share much more than that, but please let us know if you are seeing issues developing on iOS 18.4.
6 Likes