My iOS app that I created since 2011, crashes on M4 machine (M1 is fine!)

A user gave me the crash log on his M4 machine when he first launches the app. I have M1 and my app works fine, which begs the question, why M4 has the crash! This is my app the I developed since 2011 until now. Any hints will be appreciated or anyone has similar issues like to share?

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: DA1CEECB-28D4-40A9-8F0C-7125812084F4
CrashReporter Key:   FB8A5DBB-7140-D370-AC72-EC158266383C
Hardware Model:      Mac16,3
Process:             Stocks Live [5506]
Path:                /private/var/folders/*/Stocks Live.app/Stocks Live
Identifier:          com.cinnamonmobile.StocksLive
Version:             34.2 (34.2.0)
AppStoreTools:       16B39
AppVariant:          1:MacFamily20,1:18
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.cinnamonmobile.StocksLive [2018]

Date/Time:           2024-11-27 12:41:48.0456 -0500
Launch Time:         2024-11-27 12:41:47.5710 -0500
OS Version:          macOS 15.1.1 (24B2091)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_MEMORY_ERROR at 0x0000000120034000
Exception Codes: 0x000000000000000a, 0x0000000120034000
VM Region Info: 0x120034000 is in 0x120034000-0x120038000;  bytes after start: 0  bytes before end: 16383
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      CoreAnimation               120030000-120034000    [   16K] rw-/rwx SM=PRV  
--->  mapped file                 120034000-120038000    [   16K] r--/rw- SM=COW  Object_id=14630bfe
      CoreAnimation               120038000-12003c000    [   16K] r--/r-- SM=PRV  
Termination Reason: SIGNAL 10 Bus error: 10
Terminating Process: exc handler [5506]

Triggered by Thread:  0

Kernel Triage:
decmpfs - (arg = 0x80000001) compressor is not registered
APFS - (arg = 0x200040) Pagein of compressed inode failed
VM - (arg = 0x190000002d) Filesystem pagein returned an error in vnode_pagein
VM - (arg = 0x0) Page has error bit set


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   CoreFoundation                	       0x18803f48c __CFStringCreateImmutableFunnel3 + 716
1   FincancialCoreFrameWork       	       0x10358d3c4 -[MOStringDocument loadFromContents:ofType:error:] + 156
2   UIKitCore                     	       0x1ba34a67c __32-[UIDocument readFromURL:error:]_block_invoke + 104
3   libdispatch.dylib             	       0x187e20658 _dispatch_client_callout + 20
4   libdispatch.dylib             	       0x187e2fdb0 _dispatch_async_and_wait_invoke + 92
5   libdispatch.dylib             	       0x187e20658 _dispatch_client_callout + 20
6   libdispatch.dylib             	       0x187e2ef68 _dispatch_main_queue_drain + 980
7   libdispatch.dylib             	       0x187e2eb84 _dispatch_main_queue_callback_4CF + 44
8   CoreFoundation                	       0x1880f8e60 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
9   CoreFoundation                	       0x1880b8a4c __CFRunLoopRun + 1996
10  CoreFoundation                	       0x1880b7bc4 CFRunLoopRunSpecific + 588
11  HIToolbox                     	       0x193529f64 RunCurrentEventLoopInMode + 292
12  HIToolbox                     	       0x19352fd54 ReceiveNextEventCommon + 636
13  HIToolbox                     	       0x19352feb8 _BlockUntilNextEventMatchingListInModeWithFilter + 76
14  AppKit                        	       0x18bbe398c _DPSNextEvent + 660
15  AppKit                        	       0x18c523ddc -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
16  AppKit                        	       0x18bbd6a64 -[NSApplication run] + 480
17  AppKit                        	       0x18bbad2e8 NSApplicationMain + 888
18  AppKit                        	       0x18bdfb7f4 _NSApplicationMainWithInfoDictionary + 24
19  UIKitMacHelper                	       0x1a28f8b38 UINSApplicationMain + 972
20  UIKitCore                     	       0x1b99de3a8 UIApplicationMain + 148
21  Stocks Live                   	       0x102bcc058 0x102bc4000 + 32856
22  dyld                          	       0x187c50274 start + 2840

Thread 1::  Dispatch queue: UIDocument File Access
0   libsystem_kernel.dylib        	       0x187f93b8c __ulock_wait + 8
1   libdispatch.dylib             	       0x187e21048 _dlock_wait + 56
2   libdispatch.dylib             	       0x187e20dfc _dispatch_thread_event_wait_slow + 56
3   libdispatch.dylib             	       0x187e2ffc4 __DISPATCH_WAIT_FOR_QUEUE__ + 368
4   libdispatch.dylib             	       0x187e2fb70 _dispatch_sync_f_slow + 148
5   UIKitCore                     	       0x1ba351384 -[UIDocument(UIDocumentInternal) _performBlock:synchronouslyOnQueue:] + 76
6   UIKitCore                     	       0x1ba347ff0 __40-[UIDocument openWithCompletionHandler:]_block_invoke + 588
7   libdispatch.dylib             	       0x187e1e8f8 _dispatch_call_block_and_release + 32
8   libdispatch.dylib             	       0x187e20658 _dispatch_client_callout + 20
9   libdispatch.dylib             	       0x187e27c60 _dispatch_lane_serial_drain + 744
10  libdispatch.dylib             	       0x187e28768 _dispatch_lane_invoke + 380
11  libdispatch.dylib             	       0x187e337e8 _dispatch_root_queue_drain_deferred_wlh + 288
12  libdispatch.dylib             	       0x187e33034 _dispatch_workloop_worker_thread + 540
13  libsystem_pthread.dylib       	       0x187fcf3d8 _pthread_wqthread + 288
14  libsystem_pthread.dylib       	       0x187fce0f0 start_wqthread + 8

Thread 2:
0   libsystem_pthread.dylib       	       0x187fce0e8 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	       0x187fce0e8 start_wqthread + 0


Is this your code FincancialCoreFrameWork? I ask because "Financial" is spelled incorrectly, and "Framework" is one word not two, so doesn't need the W to be capitalised.

It looks like some error accessing a file? Can you put in some error handling around that?

Also, are you sure this only happens on an M4 Mac? What version of macOS?


@implementation MOStringDocument

- (instancetype)init {
    self = [super init];
    if (self) {
        // Initialize default values if needed
        self.data = @""; // Default to an empty string
    }
    return self;
}

- (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError *__autoreleasing *)outError {
    // Ensure contents is of NSData type
    if (![contents isKindOfClass:[NSData class]]) {
        if (outError) {
            *outError = [NSError errorWithDomain:@"com.cinnamonmobile.StocksLive"
                                            code:1001
                                        userInfo:@{NSLocalizedDescriptionKey: @"Invalid contents type. Expected NSData."}];
        }
        NSLog(@"[MOStringDocument] Invalid contents: %@", contents);
        return NO;
    }

    NSData *data = (NSData *)contents;

    // Check if the data is empty
    if (data.length == 0) {
        self.data = @""; // Set an empty string
        NSLog(@"[MOStringDocument] Loaded empty content.");
        return YES;
    }
    
    @try {
        // Attempt to decode the data
        NSString *decodedString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        if (!decodedString) {
            if (outError) {
                *outError = [NSError errorWithDomain:@"com.cinnamonmobile.StocksLive"
                                                code:1002
                                            userInfo:@{NSLocalizedDescriptionKey: @"Failed to decode NSData as UTF-8 string."}];
            }
            NSLog(@"[MOStringDocument] Failed to decode content as UTF-8 string.");
            return NO;
        }

        // Set the decoded string
        self.data = decodedString;
        NSLog(@"[MOStringDocument] Successfully loaded content: %@", self.data);
    } @catch (NSException *exception) {
        if (outError) {
            *outError = [NSError errorWithDomain:@"com.cinnamonmobile.StocksLive"
                                            code:1004
                                        userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Exception occurred: %@", exception.reason]}];
        }
        NSLog(@"[MOStringDocument] Exception occurred: %@", exception.reason);
    }

    return YES;
}

- (id)contentsForType:(NSString *)typeName error:(NSError *__autoreleasing *)outError {
    // Ensure self.data is valid
    if (!self.data) {
        self.data = @""; // Default to an empty string
    }

    // Convert the string to NSData
    NSData *data = [self.data dataUsingEncoding:NSUTF8StringEncoding];
    if (!data) {
        if (outError) {
            *outError = [NSError errorWithDomain:@"com.cinnamonmobile.StocksLive"
                                            code:1003
                                        userInfo:@{NSLocalizedDescriptionKey: @"Failed to encode string as NSData."}];
        }
        NSLog(@"[MOStringDocument] Failed to encode string as NSData.");
        return nil;
    }

    NSLog(@"[MOStringDocument] Successfully prepared content for saving.");
    return data;
}

@end

Please post the full crash report; see Posting a Crash Report for advice on how to do that.

Also, try to symbolicate your crash report. Specifically, symbolication should reveal a source file and line number for frame 1. That’ll help isolate the issue within your -loadFromContents:ofType:error: method.

For advice on how to symbolicate, see Adding identifiable symbol names to a crash report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

My iOS app that I created since 2011, crashes on M4 machine (M1 is fine!)
 
 
Q