Fix iOS player crash due to mimalloc symbol conflict in Unity 6.5+#152
Merged
Conversation
hkmt-mmy
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After updating Unity to 6000.5.2f1, iOS builds crash on launch (
EXC_BAD_ACCESS→ watchdogSIGKILL).Unity 6000.5 now bundles its own mimalloc in
UnityFramework(_heap_main,_mi_page_empty, etc.). Ourlibunienc_c.abundles its own mimalloc too, and on iOS it's statically linked (__Internal) into the sameUnityFramework. The identically-named symbols coalesce at link time, so unienc's mimalloc ends up using Unity's_heap_main(different ABI layout) and dereferences a bogus pointer.-fvisibility=hiddendoesn't help — on Mach-O it only makes symbols private-external, which still coalesce.Fix
Localize every non-FFI symbol in the iOS
.aas a CI post-build step, keeping only_unienc*global. No submodule/source changes.apple-exports.txt— keeps_unienc*exported (all FFI entry points, incl.unienc_UnityPluginLoad/Unload).localize-apple-staticlib.sh—ar x→ld -r -exported_symbols_list(demotes non-_unienc*globals to local) →libtool -static. Anm -gUgate fails the build if any mimalloc symbol is still external.build-unienc.yml— runs the script inbuild-ios(Unity variant), and setsCFLAGS_aarch64-apple-ios: -fno-common.Linker notes (ld-prime, Xcode 16+)
-force_load(it localizes everything, wiping the exports).-platform_versionis required even for-r.-fno-commonis required:_mi_page_mapis a common symbol otherwise and can't be localized. Injected via cc-rsCFLAGS, so no submodule change.Verification
nm -gUshows only the 34_unienc*symbols and 0 mimalloc symbols. Verified on device: launches on Unity 6000.6.0b1, Memory Profiler integration retained.