iOS application crashes on start when not debugging only

Hello,

We are experiencing a weird crash on iPad when the game starts and we don't know what's causing it.

We narrowed down it happen for os versions >= 13.x
On my iPad 12.2 the installed app was working and after updating to the latest 14.1 it started crashing on start.

Is possible to reproduce the crash in debug too however only when not debugging the executable.
The crash happens very early so that even an NSLog as first command in the main function doesn't get printed.

All the logs on device are similar and despite many searches we haven't found anything that is applicable to our case.

We tried different version of Xcode (11.7 and 12.1) but we get the same issue.

Is there anyone who can give us any clue or ideas to where we could dig further?

Thanks in advance for any suggestions!

Here's an example of the log we get:

Code Block language
OS Version: iPhone OS 14.1 (18A8395)
Release Type: User
Baseband Version: n/a
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000000016fa5a860
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [1641]
Highlighted by Thread: 0
Backtrace not available
Unknown thread crashed with ARM Thread State (64-bit):
x0: 0x00000001002a0000 x1: 0x000000016fb5e8d8 x2: 0x000000016fb46040 x3: 0x000000016fb45fc0
x4: 0x000000018d9b0000 x5: 0x000000016fb45d60 x6: 0x7366657272657075 x7: 0x0000000000000930
x8: 0x000000016fb46080 x9: 0x000000011b5df2d8 x10: 0x6ae100016fb45fc0 x11: 0x0000000000000003
x12: 0x0000000000ff0006 x13: 0x0000000010a64000 x14: 0x0000000000000005 x15: 0x0000000000000000
x16: 0x000000011b5aaa88 x17: 0x000000011b59d374 x18: 0x0000000000000000 x19: 0x000000016fb45ed0
x20: 0x000000016fb46510 x21: 0x00000001002a0000 x22: 0x000000011b3b0000 x23: 0x000000016fb5e878
x24: 0x000000016fb5e8d8 x25: 0x000000016fa5a8c0 x26: 0x000000016fb45ed0 x27: 0x0000000000000295
x28: 0x0000000000010c88 fp: 0x000000016fb46500 lr: 0x916c0a811b5a9f38
sp: 0x000000016fa5a6f0 pc: 0x000000011b59e8b0 cpsr: 0x60000000
esr: 0x00000000 Address size fault
Binary images description not available
Error Formulating Crash Report:
Failed to create CSSymbolicatorRef - corpse still valid ¯_(ツ)_/¯

Answered by dav80 in 645416022
We eventually solved the problem so I'm updating here as it may be helpful for others.

The actual crash was in dyld3:

Code Block language
Thread 1#0 0x00000001371e3d08 in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, bool, void (unsigned int) block_pointer, void const*) const ()
#1 0x00000001371ecca4 in dyld3::closure::ClosureBuilder::buildImage(dyld3::closure::ImageWriter&, dyld3::closure::ClosureBuilder::BuilderLoadedImage&) ()
#2 0x00000001371f5b20 in dyld3::closure::ClosureBuilder::makeLaunchClosure(dyld3::closure::LoadedFileInfo const&, bool) ()
#3 0x00000001371bfc0c in dyld::buildLaunchClosure(unsigned char const*, dyld3::closure::LoadedFileInfo const&, char const**) ()
#4 0x00000001371be88c in dyld::_main(macho_header const*, unsigned long, int, char const, char const, char const**, unsigned long*) ()
#5 0x00000001371b9208 in dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) ()
#6 0x00000001371b9038 in _dyld_start ()


So we realised it could have been something to do with static variables.
After narrowing down the set of changes who went in we changed a long list of 'inline const' constant into 'extern' and defined them into a cpp file.
This fixed the problem.
However we also realised that this crash happened after we passed the threshold of 128, maybe it's random maybe not, difficult to say.
For some reason from iOS 13.x (not sure about the version) the launcher seems to have this threshold.
Maybe someone can correct me.
For sure the same code works on iOS version < 13
Accepted Answer
We eventually solved the problem so I'm updating here as it may be helpful for others.

The actual crash was in dyld3:

Code Block language
Thread 1#0 0x00000001371e3d08 in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, bool, void (unsigned int) block_pointer, void const*) const ()
#1 0x00000001371ecca4 in dyld3::closure::ClosureBuilder::buildImage(dyld3::closure::ImageWriter&, dyld3::closure::ClosureBuilder::BuilderLoadedImage&) ()
#2 0x00000001371f5b20 in dyld3::closure::ClosureBuilder::makeLaunchClosure(dyld3::closure::LoadedFileInfo const&, bool) ()
#3 0x00000001371bfc0c in dyld::buildLaunchClosure(unsigned char const*, dyld3::closure::LoadedFileInfo const&, char const**) ()
#4 0x00000001371be88c in dyld::_main(macho_header const*, unsigned long, int, char const, char const, char const**, unsigned long*) ()
#5 0x00000001371b9208 in dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) ()
#6 0x00000001371b9038 in _dyld_start ()


So we realised it could have been something to do with static variables.
After narrowing down the set of changes who went in we changed a long list of 'inline const' constant into 'extern' and defined them into a cpp file.
This fixed the problem.
However we also realised that this crash happened after we passed the threshold of 128, maybe it's random maybe not, difficult to say.
For some reason from iOS 13.x (not sure about the version) the launcher seems to have this threshold.
Maybe someone can correct me.
For sure the same code works on iOS version < 13

I experienced the same issue with Xcode 14.3. However, I didn't have any problems with Xcode 14.2.

Date&#x2F;Time:           2023-04-06 12:12:46.2499 +0900
Launch Time:         2023-04-06 12:12:46.2440 +0900
OS Version:          iPhone OS 13.7 (17H35)
Release Type:        User
Baseband Version:    1.06.00
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, Assertion failed: (gotLocation), function applyFixupsToImage_block_invoke_3, file &#x2F;Library&#x2F;Caches&#x2F;com.apple.xbs&#x2F;Sources&#x2F;dyld&#x2F;dyld-750.4.2&#x2F;dyld3&#x2F;Loading.cpp, line 779.
Highlighted by Thread:  0

Backtrace not available

Unknown thread crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000006   x1: 0x0000000000000009   x2: 0x000000016b687fe0   x3: 0x0000000000000014
    x4: 0x000000016b687be0   x5: 0x0000000000000000   x6: 0x000000016b688970   x7: 0x000000016b688a88
    x8: 0x0000000000000020   x9: 0x0000000000000009  x10: 0x2e676e6964616f4c  x11: 0x6e696c202c707063
   x12: 0x2f33646c79642f32  x13: 0x2e676e6964616f4c  x14: 0x6e696c202c707063  x15: 0x000a2e3937372065
   x16: 0x0000000000000209  x17: 0x00000001054c3370  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016b687be0  x21: 0x0000000000000014  x22: 0x000000016b687fe0  x23: 0x0000000000000009
   x24: 0x0000000000000006  x25: 0x0000000000000a19  x26: 0x00000000000012f6  x27: 0x000000010535be44
   x28: 0x00000000004f7578   fp: 0x000000016b687bb0   lr: 0x00000001054d04cc
    sp: 0x000000016b687b70   pc: 0x00000001054c8d90 cpsr: 0x40000000
   esr: 0x00000000  Address size fault

Binary images description not available

Error Formulating Crash Report:
Failed to create CSSymbolicatorRef - corpse still valid ¯\_(ツ)_&#x2F;¯

EOF
iOS application crashes on start when not debugging only
 
 
Q