Search Issue Tracker

By Design

Votes

2

Found in

2019.3

2019.3.14f1

Issue ID

1251582

Regression

No

[iOS] [IL2CPP] crash on il2cpp::os::Image::Initialize() on Application launch

iOS

-

Reproduction steps:
1. Open user's attached project in "NativePluginsWithInstagramAndSnapchatKits.zip"
2. Go Edit -> Build Settings and remove InstagramKitDemo Scene from the build
3. Build for iOS and open Xcode project generated
4. Select RegisterMonoModules.cpp in Xcode file browser
5. Disable all Target Memberships (Disable.png, this will resolve linker errors)
6. Remove Game Center Capability (Remove.png)
7. Deploy the project (read Note)

Unexpected behavior: upon launch, the game crashes at il2cpp::os::Image::Initialize()

Reproducible with: 2019.3.15f1
Could not test with 2020.1, 2020.2 because of errors in Xcode (X is ambiguous), 2018.4, because of errors in Unity (serialized with a newer version of Unity)

Devices tested:
Reproducible with:
VLNQA00310 iPad Pro 12.9 (iOS 13.4.1)
Does not reproduce with:
N/A, Samsung Galaxy S9 (SM-G960F), Android 8.0.0, CPU: Exynos 9 Series 9810, GPU: Mali-G72
VLNQA00313, Huawei Y6 Ⅱ Compact (HUAWEI LYO-L01), Android 5.1, CPU: MediaTek MT6735, GPU: Mali-T720
VLNQA00140, Samsung Galaxy S4 (GT-I9505), Android 5.0.1, CPU: Snapdragon S4 Plus MSM8960, GPU: Adreno (TM) 320
Could not test with:
VLNQA00204 iPhone 5C (iOS 10.3.3) - unsupported Architecture

Note: Sometimes Indexing takes a while before Xcode starts building

Few lines from stack trace (full stack trace in edits):
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
frame #0: 0x00000001031fd59c UnityFramework`il2cpp::os::Image::Initialize() + 92
frame #1: 0x0000000103216214 UnityFramework`il2cpp::vm::Runtime::Init(char const*) + 180
....
* frame #44: 0x0000000102067e1c InstagramAndSnapchatKits`main(argc=<unavailable>, argv=<unavailable>) at main.mm:26:9 [opt]
frame #45: 0x0000000183c77800 libdyld.dylib`start + 4

  1. Response avatar

    Resolution Note:

    User error.
    The project contains editor scripts that do modify exported XCode project. Haven't investigated those scripts, but the issue is caused by improper project modification.
    In exported XCode project:
    - Select Unity-iPhone
    - Select UnityFramework (under Targets)
    - Go to Build Settings tab
    - Find section "Apple Clang - Custom Compiler Flags"

    When simple project is exported from Unity, C and C++ flags are identical.
    In users repro for C++ there is only "-fcxx-modules". This causes the issue with RegisterMonoModules.cpp you are working around and the crash. The later most likely due to "-DRUNTIME_IL2CPP=1" lost, though haven't investigated that deeply.
    Basically:
    - Copy flags from C to C++ (leave the present flag, just append those from C) and the project builds and runs fine (and you should be able to add RegisterMonoModules.cpp back with no compilation errors).
    - The proper fix is to edit Editor scripts so that they add -fcxx-modules flag without losing what we set by default.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.