Some iOS 9 devices in the wild seem to crash with the error message that I receive from the very basic crash reporting in Xcode only
dyld: malformed mach-o: load commands size (16464) > 16384
Unfortunately that's all the info I get. I can't even debug or reproduce locally. Can anyone hint me into the right direction here?
It occurs after updating my Cocoapods, so I guess there's one of them (or their dependency) that misbehaves.
After some investigation of my mach-O binary, I saw that the sizeofcmds
is really 16464.
If I understand correctly, there seems to be a load command size limit of 16384, can anyone confirm this?
Does that mean I should remove dylibs and everything should be fine?
At WWDC18 I went to an Apple engineer who is working on dyld
. Here’s what he had to say:
otool -L
to see themPossible solutions:
-reexport-l
as a linker flag (not done often) → gonna make some runtime overhead when starting the app, also uses a bit more memory (man ld
→ for info on re-exports)The engineer recommended to file a bugreport via bugreport.apple.com, because in the future even hitting the 32k limit is possible.
I found a solution that will (at least temporarily) work for me - but I still encourage everyone to provide a real solution and more detailed insights.
Anyway:
YourApp.ipa
to YourApp.zip
and extractYourApp.app
Show Package Contents
of your YourApp.app
fileYourApp
(no file extension) to a different locationotool -f
on your binaryNote the align
for both architectures are listed which, for me, says 2^14 (16384). This seems to be the threshold for the size of load commands.
otool -l
on your binaryYou'll see that the different architectures and their load commands are listed - as well as their sizeofcmds
(size of commands).
Now the funny thing:
For arm64, the sizeofcmds
(16464) was larger than the align (16384), while it wasn't for armv7.
Now I haven't found enough documentation on this, but I assume that align symbolizes a threshold that should not be reached by the load command size. And also that it adjusts automatically (since we are definitely not having that many frameworks in our app, there have to be apps that have more).
So I guess the error came from this unlikely case, that the sizeofcmds
was different in between the architectures AND that one of them was actually valid (so that the align was not automatically adjusted).
Please correct me if I'm wrong, I am just assuming here and I really really want to understand why this happens.
Remove frameworks until you are under the sizeofcmds
for both architectures.
I know this is not scalable, we were lucky (and stupid) that we still had one barely used framework in there that we could easily remove.
Fortunately this only seems to be an issue on iOS9 and will therefore loose relevance over the next months, nevertheless, we should find out if I'm right
My assumption that the align is automatically adjusted could be investigated by just putting in more and more frameworks to see if it actually does.
If so, adding frameworks would also solve the original issue - not nice, but at least slightly more scalable.
I don't feel like I shed enough light on the origins of this issue and I had a lot of assumptions. While my solution works, I really hope you feel encouraged to investigate this as well and give a better answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With