Crashes on iOS devices

Godot Version

Godot 3.5.1

Other Info

MacBook Pro, Apple M1
macOS, Ventura, 13.5
Xcode, 15.2
iPad Air (5th generation), 17.4.1

Question

Hello!

We are experiencing crashes on iOS both in debug and release builds. The main problem is that we don’t know where exactly the problem is and cannot understand how could we find a way to fix it.

Debug builds:

It is way more frequent in debug builds when we make a build, open it in Xcode, and install it directly on an iOS device. The first type of the crash in debug build is occurring like 70% of the time when the game is loading and trying to get into its main menu. The thing we are getting in Xcode looks like Image 1. Another type of crash happens when we open some save files and start the actual playable part of the game. It happens just after moving the character a few steps and it looks like Image 2. We are aware that the log recommends using breakpoints to find where exactly the problem is, but the thing is that we don’t know where we could do that in Xcode. We are not sure if we are missing something in Xcode or if we cannot do that when opening a project made in Godot. We tried many different builds with removed shader files, and scenes and changed different kinds of settings.

We would get the same crash every time. When we made a new build, we cleared the build’s folder. Also, we occasionally deleted the .import folder of the project during development and reimported it. The problem also occurred on other iOS test devices with more than 4GB of RAM.

Release builds:

These builds are uploaded on TestFlight. In release builds crashes wouldn’t occur like in debug builds. They would happen like totally randomly. In some testing sessions, it would happen like 10 minutes in the game, and in others in a few hours. Some testers couldn’t get the crash and altogether, we couldn’t find some repro steps to produce these crashes. In the attached files, you can find logs that we managed to collect from TestFlight. The most frequent type of the crash that we got, is following:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS

From reading Apple’s documentation (Investigating memory access crashes | Apple Developer Documentation), we got it that the problem is in “Invalid memory fetch”, but we couldn’t find how this could help us with further investigation.

If you have some clues or ideas on how to fix this problem, please write it, it would mean us a lot. Don’t hesitate to ask questions if something is unclear.

Thank you very much in advance! Cheers!

Attached files:

Links to mentioned Image 1 and Image 2

Crash log on release build:

Incident Identifier: *project_codes*
Distributor ID:      com.apple.TestFlight
Hardware Model:      iPhone14,3
Process:             project_name_ios [2178]
Path:                /private/var/containers/Bundle/Application/*project_codes*/project_name_ios.app/project_name_ios
Identifier:          com.companyname.projectname
Version:             1.0 (16)
AppStoreTools:       15C5500a
AppVariant:          1:iPhone14,3:17
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.companyname.projectname [762]

Date/Time:           2024-04-29 20:24:05.6708 +0200
Launch Time:         2024-04-29 19:07:02.6859 +0200
OS Version:          iPhone OS 17.4.1 (21E236)
Release Type:        User
Baseband Version:    3.50.04
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Codes: 0x0000000000000001, 0x0000000000000020
VM Region Info: 0x20 is not in any region.  Bytes before following region: 4344856544
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   102f94000-102f9c000 [   32K] r-x/r-x SM=COW  /var/containers/Bundle/Application/*project_codes*/project_name_ios.app/project_name_ios
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [2178]

Triggered by Thread:  0


Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter


Thread 0 name:
Thread 0 Crashed:
0   project_name_ios            	0x00000001041c8c7c predelete_handler(Object*) + 24
1   project_name_ios            	0x0000000103564974 Node::_notification(int) + 136
2   QuartzCore                    	0x000000019257bf30 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 868 (CADisplay.mm:4945)
3   QuartzCore                    	0x00000001925fa654 CA::Display::DisplayLink::dispatch_deferred_display_links(unsigned int) + 352 (CADisplay.mm:4070)
4   UIKitCore                     	0x00000001931fcd78 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:119)
5   UIKitCore                     	0x00000001931fc468 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1037)
6   UIKitCore                     	0x00000001931fc524 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1186)
7   CoreFoundation                	0x0000000190f0d62c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957)
8   CoreFoundation                	0x0000000190f0c8a8 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001)
9   CoreFoundation                	0x0000000190f0b058 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038)
10  CoreFoundation                	0x0000000190f09d88 __CFRunLoopRun + 828 (CFRunLoop.c:2955)
11  CoreFoundation                	0x0000000190f09968 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
12  GraphicsServices              	0x00000001d51ff4e0 GSEventRunModal + 164 (GSEvent.c:2196)
13  UIKitCore                     	0x000000019337cedc -[UIApplication _run] + 888 (UIApplication.m:3692)
14  UIKitCore                     	0x000000019337c518 UIApplicationMain + 340 (UIApplication.m:5282)
15  project_name_ios            	0x0000000102f9dd98 main + 124

Thread 1 name:
Thread 1:
0   libsystem_kernel.dylib        	0x00000001d9431af8 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001d9431890 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001d94317a8 mach_msg_overwrite + 436 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001d94315e8 mach_msg + 24 (mach_msg.c:323)
4   CoreFoundation                	0x0000000190f0c01c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
5   CoreFoundation                	0x0000000190f09f04 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
6   CoreFoundation                	0x0000000190f09968 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
7   Foundation                    	0x000000018fd984a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
8   Foundation                    	0x000000018fdc24e8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420)
9   UIKitCore                     	0x00000001932dfac8 -[UIEventFetcher threadMain] + 420 (UIEventFetcher.m:1201)
10  Foundation                    	0x000000018fe09a9c __NSThread__start__ + 732 (NSThread.m:991)
11  libsystem_pthread.dylib       	0x00000001eceb9a90 _pthread_start + 136 (pthread.c:927)
12  libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 2:
0   libsystem_kernel.dylib        	0x00000001d943249c __psynch_cvwait + 8 (:-1)
1   libsystem_pthread.dylib       	0x00000001eceb8590 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2   libc++.1.dylib                	0x00000001a12ae504 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (condition_variable.cpp:45)
3   project_name_ios            	0x0000000104359570 _IP_ResolverPrivate::_thread_function(void*) + 156
4   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 3 name:
Thread 3:
0   libsystem_kernel.dylib        	0x00000001d9431af8 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001d9431890 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001d94317a8 mach_msg_overwrite + 436 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001d94315e8 mach_msg + 24 (mach_msg.c:323)
4   CoreFoundation                	0x0000000190f0c01c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
5   CoreFoundation                	0x0000000190f09f04 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
6   CoreFoundation                	0x0000000190f09968 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
7   CoreFoundation                	0x0000000190f096cc CFRunLoopRun + 64 (CFRunLoop.c:3446)
8   CoreMotion                    	0x000000019ded63c0 CLMotionCore::runMotionThread(void*) + 1292 (CLMotionCore.mm:376)
9   libsystem_pthread.dylib       	0x00000001eceb9a90 _pthread_start + 136 (pthread.c:927)
10  libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 4:
0   libsystem_kernel.dylib        	0x00000001d943249c __psynch_cvwait + 8 (:-1)
1   libsystem_pthread.dylib       	0x00000001eceb8590 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2   libc++.1.dylib                	0x00000001a12ae504 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (condition_variable.cpp:45)
3   project_name_ios            	0x0000000103fd05f0 VisualServerScene::_gi_probe_bake_thread() + 160
4   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 5 name:
Thread 5:
0   libsystem_kernel.dylib        	0x00000001d9431a74 semaphore_wait_trap + 8 (:-1)
1   caulk                         	0x0000000201da7610 caulk::semaphore::timed_wait(double) + 212 (semaphore.cpp:98)
2   caulk                         	0x0000000201da7440 caulk::concurrent::details::worker_thread::run() + 36 (messenger.cpp:234)
3   caulk                         	0x0000000201dc07bc void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*>>>(void*) + 96 (thread.h:189)
4   libsystem_pthread.dylib       	0x00000001eceb9a90 _pthread_start + 136 (pthread.c:927)
5   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 6 name:
Thread 6:
0   libsystem_kernel.dylib        	0x00000001d9431a74 semaphore_wait_trap + 8 (:-1)
1   caulk                         	0x0000000201da7610 caulk::semaphore::timed_wait(double) + 212 (semaphore.cpp:98)
2   caulk                         	0x0000000201da7440 caulk::concurrent::details::worker_thread::run() + 36 (messenger.cpp:234)
3   caulk                         	0x0000000201dc07bc void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*>>>(void*) + 96 (thread.h:189)
4   libsystem_pthread.dylib       	0x00000001eceb9a90 _pthread_start + 136 (pthread.c:927)
5   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 7 name:
Thread 7:
0   libsystem_kernel.dylib        	0x00000001d943249c __psynch_cvwait + 8 (:-1)
1   libsystem_pthread.dylib       	0x00000001eceb8590 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2   libc++.1.dylib                	0x00000001a12ae504 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (condition_variable.cpp:45)
3   project_name_ios            	0x00000001043c9da8 _Semaphore::wait() + 76
4   project_name_ios            	0x00000001041c06a8 Object::call(StringName const&, Variant const**, int, Variant::CallError&) + 136
5   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 8 name:
Thread 8:
0   libsystem_kernel.dylib        	0x00000001d943249c __psynch_cvwait + 8 (:-1)
1   libsystem_pthread.dylib       	0x00000001eceb8590 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2   libc++.1.dylib                	0x00000001a12ae504 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (condition_variable.cpp:45)
3   project_name_ios            	0x00000001043c9da8 _Semaphore::wait() + 76
4   project_name_ios            	0x00000001041c06a8 Object::call(StringName const&, Variant const**, int, Variant::CallError&) + 136
5   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 9 name:
Thread 9:
0   libsystem_kernel.dylib        	0x00000001d9431af8 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001d9431890 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001d94317a8 mach_msg_overwrite + 436 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001d94315e8 mach_msg + 24 (mach_msg.c:323)
4   libEmbeddedSystemAUs.dylib    	0x000000020b609548 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, AURemoteIO::IOThread::IOThread(AURemoteIO&, caulk::thread::attributes const&, caulk::mach::os_workgroup_managed const&)::'lambda... + 556 (thread.h:189)
5   libsystem_pthread.dylib       	0x00000001eceb9a90 _pthread_start + 136 (pthread.c:927)
6   libsystem_pthread.dylib       	0x00000001eceb8fcc thread_start + 8 (:-1)

Thread 10:
0   libsystem_pthread.dylib       	0x00000001eceb8fb8 start_wqthread + 0 (:-1)

Thread 11:
0   libsystem_pthread.dylib       	0x00000001eceb8fb8 start_wqthread + 0 (:-1)

Thread 12:
0   libsystem_pthread.dylib       	0x00000001eceb8fb8 start_wqthread + 0 (:-1)


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x000000016387ca60   x1: 0x0000000104873c00   x2: 0x0000000163800000   x3: 0x000000016387ca60
    x4: 0x0000000000000001   x5: 0x000000016387ca60   x6: 0x0000000000000096   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x0000000000000000  x10: 0x000000000015e970  x11: 0x0000000000179f41
   x12: 0x0000000000000789  x13: 0x0000000040000010  x14: 0x0000000040000010  x15: 0x00000001f14d0000
   x16: 0xd796000104868080  x17: 0x000000016387ca60  x18: 0x0000000000000000  x19: 0x000000016387ca60
   x20: 0x000000016387ca60  x21: 0x00000001044858cf  x22: 0x000000010448589a  x23: 0x00000001044858ff
   x24: 0x000000016de84530  x25: 0x0000000000000000  x26: 0x000000010472f000  x27: 0x0000000000000001
   x28: 0x0000000000000000   fp: 0x000000016ce6a5c0   lr: 0x0000000103564974
    sp: 0x000000016ce6a1c0   pc: 0x00000001041c8c7c cpsr: 0x20001000
   esr: 0x92000006 (Data Abort) byte read Translation fault


Binary Images:
        0x102f94000 -         0x10467ffff project_name_ios arm64  <d54ea62362cb35f1af67298ec3a10595> /private/var/containers/Bundle/Application/*project_codes*/project_name_ios.app/project_name_ios
        0x104b3c000 -         0x104b47fff libobjc-trampolines.dylib arm64e  <19bc6b58cbf535a583a5fc742451547d> /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib
        0x18fd6d000 -         0x1908f8fff Foundation arm64e  <d92e19c162993e948614c505d5abccdb> /System/Library/Frameworks/Foundation.framework/Foundation
        0x190ed6000 -         0x191403fff CoreFoundation arm64e  <3a5f992ad1cd312ebd2ef7c66343a417> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
        0x192549000 -         0x1928d1fff QuartzCore arm64e  <a53570f9dc4a3b419932b1a081e6e520> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
        0x193152000 -         0x194c62fff UIKitCore arm64e  <7bf01cfc23f1326aafd8ad967ffece28> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
        0x198e16000 -         0x198e93fff libsystem_c.dylib arm64e  <3b5201c515d0335fa91d0c63e1f6c6dc> /usr/lib/system/libsystem_c.dylib
        0x19dbed000 -         0x19e0b6fff CoreMotion arm64e  <1e51658a881b3bbb95c26c7c9701e878> /System/Library/Frameworks/CoreMotion.framework/CoreMotion
        0x1a12a1000 -         0x1a132afff libc++.1.dylib arm64e  <0682656017af331a8255de4246279bca> /usr/lib/libc++.1.dylib
        0x1d51fc000 -         0x1d5204fff GraphicsServices arm64e  <4cb7e98636bf38018f495d8c3c4a2127> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
        0x1d9430000 -         0x1d9469fef libsystem_kernel.dylib arm64e  <db493af363b132209dd8dd4f86bddfc8> /usr/lib/system/libsystem_kernel.dylib
        0x1eceb7000 -         0x1ecec3fff libsystem_pthread.dylib arm64e  <a70c0def058c3cb09ec1453aa7f39df9> /usr/lib/system/libsystem_pthread.dylib
        0x201da6000 -         0x201dcffff caulk arm64e  <b669678948863c27a2d9b298aa50ab08> /System/Library/PrivateFrameworks/caulk.framework/caulk
        0x20b567000 -         0x20b677ff7 libEmbeddedSystemAUs.dylib arm64e  <e2c03649c5df34d59e8cfeed54377b8c> /System/Library/Frameworks/AudioToolbox.framework/libEmbeddedSystemAUs.dylib

EOF