Open lewismacnow opened 2 months ago
If Ollama is not running yet, the crash does not happen. As soon as you start Ollama and start a new chat, the App crashes. If Ollama is already running when launching the App, it crashes immediately.
Before building Ollama you have to update the dependencies to the latest main/master branches, as some packages have issues building with latest Xcode beta.
If Ollama is not running yet, the crash does not happen. As soon as you start Ollama and start a new chat, the App crashes. If Ollama is already running when launching the App, it crashes immediately.
Before building Ollama you have to update the dependencies to the latest main/master branches, as some packages have issues building with latest Xcode beta.
Hows is Ollama relevent to the issues? Ollama runs on container on a remote server in my case
If Ollama is not running yet, the crash does not happen. As soon as you start Ollama and start a new chat, the App crashes. If Ollama is already running when launching the App, it crashes immediately. Before building Ollama you have to update the dependencies to the latest main/master branches, as some packages have issues building with latest Xcode beta.
Hows is Ollama relevent to the issues? Ollama runs on container on a remote server in my case
It seems like as long as Enchanted is not connected to Ollama, everything is fine. As soon as a connection to Ollama is established, Enchanted tries to get the installed models. Something in this logic seems to be wrong, or maybe an update in SwiftData from Apple causes the crash.
I think @AugustDev has to check this to make Enchanted compatible with upcoming major releases of Apple's operating systems.
Investigating and fixing Asap!
Mhm, I'm not able to reproduce. I downloaded XCode 16 Beta to be able to run on iOS 18.
Can you share more details of how to reproduce?
Mhm, I'm not able to reproduce. I downloaded XCode 16 Beta to be able to run on iOS 18.
Can you share more details of how to reproduce?
* Are you running on iOS 18 simulator or macOS 15? * Does the issue happen when you build the app yourself or also using official App Store version?
I am running Version 15.0 Beta (24A5264n) on a macbook pro (And iOS 18 beta, directly on the iPhone) Here is an example of it crashing on the macbook https://github.com/AugustDev/enchanted/assets/93997957/776bac09-c780-4b71-a90b-c1f630488ba0
This is an AI generated summary of that error log we saw:
The crash log indicates that process Enchanted (PID 6481) experienced a SIGTRAP exception and EXC_BREAKPOINT with codes (0x0000000000000001, 0x00000001ab2c98b4) at thread ID 0. This is most likely caused by an invalid memory access or a breakpoint set in the code.
To further diagnose the issue:
Binary Image Inspection: The crash appears to be within libswiftCore.dylib and libdispatch.dylib, suggesting that it's related to Swift runtime or threading. The call stack points to internal Swift functions like _assertionFailure and methods from NSManagedObjectContext. VM Region Summary: The log shows significant memory regions being used by libraries and other processes, with some unallocated memory at 1.8GB. This doesn't directly point to the cause but could indicate potential issues related to memory management or fragmentation. External Modification Summary: No external modifications are made suggesting that no process is attempting to modify the target process's state during the crash. Crash Location: The crash happens in libswiftCore.dylib's _KeyedEncodingContainerBox.encodeNil<A>(forKey:) function, indicating a potential issue with encoding objects into a key-value encoding container (like NSJSONSerialization or another Swift serialization mechanism).
To resolve the issue:
Review Swift Code: Check for any modifications made in Enchanted codebase related to the use of _assertionFailure and the serialization paths through libswiftCore.dylib. Check Core Data Usage: Since NSManagedObjectContext is involved, verify that operations are correctly handling nulls or invalid states within a context. Review Memory Management: Ensure proper memory management (allocation, deallocation) to prevent out-of-bound accesses. Swift automatically manages memory with ARC but manual errors can still occur.
Given the complexity and detail of the crash report and binary images, it would be beneficial for an engineer familiar with Swift or macOS application development to review this log further and potentially reproduce the issue in a test environment to isolate the root cause.
Mhm, I'm not able to reproduce. I downloaded XCode 16 Beta to be able to run on iOS 18.
Can you share more details of how to reproduce?
- Are you running on iOS 18 simulator or macOS 15?
- Does the issue happen when you build the app yourself or also using official App Store version?
I was using latest macOS Developer Beta with latest Xcode Developer Beta. I downloaded the source code of Enchanted to my macOS and compiled it work usage on my local machine.
At first it didn't compile, as a required markdown library could not be compiled. Changing the markdown library to "main" branch worked.
Crashes happend for:
It works as long as Ollama is not running on start up. As soon as Ollama is started, it seems like Enchanted connects to Ollama (which is running on my localhost) and then always crashes immediately and reproducibly. If Ollama is already running before starting Enchanted, it is crashing immediately on startup.
The crash happens at the code line above as seen in screenshot in my previous post. (SwiftDataService.swift, line 47)
Just wanted to confirm there is indeed a sort of an issue with the latest betas. Unfortunately, I have just downgraded back to Sonoma and cannot provide logs (I should've though of that, obviously), but what was happening is it would work for one request using the shortcut key combo - but then the app was becoming unresponsive and I had to kill it. Every time it would work exactly once, and then would just freeze.
Not sure if this description is helpful in any way, but just in case - here is the setup I used:
macOS 15.0 Developer Beta 2 Xcode Developer Beta 2
Opens fine as long as Ollama is not running. Start Ollama, still everything fine. No models in dropdown available. Create a new chat, Enchanted crashes.
Latest version from the App Store, running on an iPhone 15 PM and iOS 18, seems to be running fine so far, however deleting conversations consistently crashes the app. I was able to delete a couple, but now left with the first 2 conversations I'd created, with no way to remove them. Note that they use different models, in case it matters.
I'm on Beta, and I can say that for everything; so far so good on both iOS, MacOS, iPadOS.
I'm on Beta, and I can say that for everything; so far so good on both iOS, MacOS, iPadOS.
macOS Version 15.0 Beta (24A5298h)
Enchanted still crashes as soon as it loads the models from Ollama.
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Enchanted [28220]
Path: /Applications/Enchanted.app/Contents/MacOS/Enchanted
Identifier: subj.Enchanted
Version: 1.7.2 (50)
App Item ID: 6474268307
App External ID: 866907511
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 501
Date/Time: 2024-08-02 23:00:50.2634 +0200
OS Version: macOS 15.0 (24A5298h)
Report Version: 12
Anonymous UUID: BC118DCC-46B5-C9E2-3DC1-AF5074B262ED
Sleep/Wake UUID: 377C9B95-4CE6-48B3-ADD5-2F4D2213B7D6
Time Awake Since Boot: 140000 seconds
Time Since Wake: 2782 seconds
System Integrity Protection: enabled
Crashed Thread: 0
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001b1071760
Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process: exc handler [28220]
Thread 0 Crashed:
0 libswiftCore.dylib 0x1b1071760 _assertionFailure(_:_:file:line:flags:) + 268
1 SwiftData 0x23b1a1dc0 0x23b162000 + 261568
2 SwiftData 0x23b1aa2a4 0x23b162000 + 295588
3 SwiftData 0x23b1ac3b4 0x23b162000 + 304052
4 libswiftCore.dylib 0x1b109572c _KeyedEncodingContainerBox.encodeNil<A>(forKey:) + 352
5 libswiftCore.dylib 0x1b1088fe0 KeyedEncodingContainer.encodeNil(forKey:) + 64
6 SwiftData 0x23b1b5a24 0x23b162000 + 342564
7 SwiftData 0x23b1ba638 0x23b162000 + 362040
8 libswiftCore.dylib 0x1b13cd5a8 dispatch thunk of Encodable.encode(to:) + 32
9 SwiftData 0x23b1e3dc4 0x23b162000 + 531908
10 SwiftData 0x23b1e398c 0x23b162000 + 530828
11 SwiftData 0x23b1f0380 0x23b162000 + 582528
12 SwiftData 0x23b203d18 0x23b162000 + 662808
13 SwiftData 0x23b1ef0bc 0x23b162000 + 577724
14 SwiftData 0x23b2007a0 0x23b162000 + 649120
15 SwiftData 0x23b1ef17c 0x23b162000 + 577916
16 SwiftData 0x23b2048a8 0x23b162000 + 665768
17 Enchanted 0x102733704 0x1026c8000 + 440068
18 Enchanted 0x102708bb8 0x1026c8000 + 265144
19 Enchanted 0x1026f43ed 0x1026c8000 + 181229
20 Enchanted 0x1026f5609 0x1026c8000 + 185865
21 libswift_Concurrency.dylib 0x2794ce851 completeTask(swift::AsyncContext*, swift::SwiftError*) + 1
Thread 1:
0 libsystem_kernel.dylib 0x19fb1db8c __ulock_wait + 8
1 libdispatch.dylib 0x19f9ab048 _dlock_wait + 56
2 libdispatch.dylib 0x19f9aadfc _dispatch_thread_event_wait_slow + 56
3 libdispatch.dylib 0x19f9b9fc4 __DISPATCH_WAIT_FOR_QUEUE__ + 368
4 libdispatch.dylib 0x19f9b9b70 _dispatch_sync_f_slow + 148
5 CoreData 0x1a6adfdd0 -[NSManagedObjectContext performBlockAndWait:] + 320
6 SwiftData 0x23b17dd04 0x23b162000 + 113924
7 libswift_Concurrency.dylib 0x27946cfe8 _swift_task_enqueueOnExecutor + 100
8 libswift_Concurrency.dylib 0x2794c960c swift::AsyncTask::flagAsAndEnqueueOnExecutor(swift::SerialExecutorRef) + 432
9 libswift_Concurrency.dylib 0x2794c7aa4 swift_task_switchImpl(swift::AsyncContext*, void (swift::AsyncContext* swift_async_context) swiftasynccall*, swift::SerialExecutorRef) + 640
10 Enchanted 0x1026f43ed 0x1026c8000 + 181229
11 Enchanted 0x1026f5609 0x1026c8000 + 185865
12 libswift_Concurrency.dylib 0x2794ce851 completeTask(swift::AsyncContext*, swift::SwiftError*) + 1
Thread 2:
0 libsystem_pthread.dylib 0x19fb580e8 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x19fb580e8 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x19fb580e8 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x19fb580e8 start_wqthread + 0
Thread 6:
0 libsystem_pthread.dylib 0x19fb580e8 start_wqthread + 0
Thread 7:: Dispatch queue: com.apple.CFNetwork.CacheDB-write
0 libsystem_kernel.dylib 0x19fb1d6e4 pread + 8
1 libsqlite3.dylib 0x1a6f55344 seekAndRead + 92
2 libsqlite3.dylib 0x1a6ebc2c0 unixRead + 208
3 libsqlite3.dylib 0x1a6ed20c4 readDbPage + 216
4 libsqlite3.dylib 0x1a6f5ff38 getPageNormal + 544
5 libsqlite3.dylib 0x1a6f6ea78 getAndInitPage + 124
6 libsqlite3.dylib 0x1a6ef0cc0 moveToRoot + 576
7 libsqlite3.dylib 0x1a6f6b474 sqlite3BtreeIndexMoveto + 276
8 libsqlite3.dylib 0x1a6f05ee8 sqlite3BtreeInsert + 652
9 libsqlite3.dylib 0x1a6ee9c0c sqlite3VdbeExec + 17008
10 libsqlite3.dylib 0x1a6ee5064 sqlite3_step + 964
11 CFNetwork 0x1a5557efc -[NSURLStorageURLCacheDB stepSQLStatement:toCompletionWithRetry:] + 36
12 CFNetwork 0x1a54a1234 invocation function for block in __CFURLCache::CreateAndStoreCacheNode(__CFURLCacheNode*, _CFCachedURLResponse const*, __CFString const*, _CFURLRequest const*, void const*, bool, bool&) + 2152
13 libdispatch.dylib 0x19f9b9870 _dispatch_block_async_invoke2 + 148
14 libdispatch.dylib 0x19f9aa658 _dispatch_client_callout + 20
15 libdispatch.dylib 0x19f9b1c60 _dispatch_lane_serial_drain + 744
16 libdispatch.dylib 0x19f9b279c _dispatch_lane_invoke + 432
17 libdispatch.dylib 0x19f9bd7e8 _dispatch_root_queue_drain_deferred_wlh + 288
18 libdispatch.dylib 0x19f9bd034 _dispatch_workloop_worker_thread + 540
19 libsystem_pthread.dylib 0x19fb593d8 _pthread_wqthread + 288
20 libsystem_pthread.dylib 0x19fb580f0 start_wqthread + 8
Thread 8:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x19fb1be34 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x19fb2e5d0 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x19fb249d8 mach_msg_overwrite + 480
3 libsystem_kernel.dylib 0x19fb1c17c mach_msg + 24
4 CoreFoundation 0x19fc4673c __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x19fc44fec __CFRunLoopRun + 1212
6 CoreFoundation 0x19fc444b4 CFRunLoopRunSpecific + 572
7 AppKit 0x1a38ad4f8 _NSEventThread + 148
8 libsystem_pthread.dylib 0x19fb5d2e4 _pthread_start + 136
9 libsystem_pthread.dylib 0x19fb580fc thread_start + 8
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000600000c87a88 x1: 0x0000000200000003 x2: 0x0000000000000000 x3: 0x00006000010775c0
x4: 0x0000600001077600 x5: 0x0000000000000013 x6: 0x0000000000000020 x7: 0x0000000000000000
x8: 0xfffffffe00000000 x9: 0x0000000200000003 x10: 0x0000000000000003 x11: 0x0000000000003580
x12: 0x00000000000007fb x13: 0x00000000000007fd x14: 0x00000000cd20a06c x15: 0x00000000cd009ffb
x16: 0x00000000cd200000 x17: 0x000000000000006c x18: 0x0000000000000000 x19: 0x000000023b276420
x20: 0x0000600000c87a80 x21: 0x0000000000000000 x22: 0x000000000000000b x23: 0x000000000000001b
x24: 0x00000000000006e2 x25: 0x000000023b2732a0 x26: 0xf000000000000064 x27: 0x0000000000000000
x28: 0x0000000102bea998 fp: 0x000000016d734ab0 lr: 0x00000001b1071760
sp: 0x000000016d7349e0 pc: 0x00000001b1071760 cpsr: 0x60001000
far: 0x0000000000000000 esr: 0xf2000001 (Breakpoint) brk 1
Binary Images:
0x1026c8000 - 0x102bdffff subj.Enchanted (1.7.2) <9835a3c7-5eb6-38f6-a89c-3c3ae4b08fdc> /Applications/Enchanted.app/Contents/MacOS/Enchanted
0x104f64000 - 0x104f6ffff libobjc-trampolines.dylib (*) <22d17f68-169f-35d5-8030-5e4cf575b238> /usr/lib/libobjc-trampolines.dylib
0x10feac000 - 0x1105cffff com.apple.AGXMetalG14G (320.23.2) <60c0c123-25d7-38b0-8832-e5250bcbeef3> /System/Library/Extensions/AGXMetalG14G.bundle/Contents/MacOS/AGXMetalG14G
0x1b1039000 - 0x1b15e5fff libswiftCore.dylib (*) <bcef2e0b-74ea-364a-b60d-d4fada236186> /usr/lib/swift/libswiftCore.dylib
0x23b162000 - 0x23b297fff com.apple.SwiftData (1.0) <3ec4437f-4b2b-34cc-b7bd-a9bf93523400> /System/Library/Frameworks/SwiftData.framework/Versions/A/SwiftData
0x279467000 - 0x2794e6fff libswift_Concurrency.dylib (*) <4282f9f2-abb1-3984-89f8-c153cbc0130b> /usr/lib/swift/libswift_Concurrency.dylib
0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
0x19fb1b000 - 0x19fb55ff7 libsystem_kernel.dylib (*) <2f22b6fb-7929-3452-af97-7b074cf9270f> /usr/lib/system/libsystem_kernel.dylib
0x19f9a6000 - 0x19f9ecfff libdispatch.dylib (*) <d9eadb96-27d0-3cda-8f71-1947d88a2021> /usr/lib/system/libdispatch.dylib
0x1a6ab2000 - 0x1a6e9afff com.apple.CoreData (120) <4fdd5c8e-f41e-33ac-916f-4d71d291da71> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x19fb56000 - 0x19fb62fff libsystem_pthread.dylib (*) <59673c9d-4337-3728-8375-fd6cf6cdfbaa> /usr/lib/system/libsystem_pthread.dylib
0x1a6eb5000 - 0x1a7067ffb libsqlite3.dylib (*) <ddd8462f-ac5e-3d4a-ac36-e16e72cef179> /usr/lib/libsqlite3.dylib
0x1a5393000 - 0x1a5758fff com.apple.CFNetwork (1.0) <c7221ed2-6d0f-37db-8b1c-b0d1865e8ad3> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x19fbc8000 - 0x1a00bdfff com.apple.CoreFoundation (6.9) <81bf5987-3619-3ded-8c67-353c067ba79a> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x1a374d000 - 0x1a4c70fff com.apple.AppKit (6.9) <ea4dbbf0-9bf4-35a6-b610-d22ca3bfd730> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
I'm on Beta, and I can say that for everything; so far so good on both iOS, MacOS, iPadOS.
macOS Version 15.0 Beta (24A5298h)
Enchanted still crashes as soon as it loads the models from Ollama.
Thanks for confirming. I can no longer test macOS 15 because I restored 14.5.
But on iOS 18 beta 4, I deleted the app and redownloaded from the app store. This worked. No more crashing.
But on iOS 18 beta 4, I deleted the app and redownloaded from the app store. This worked. No more crashing.
Have never thought about this, but I tried the same. Deleting current installation (including all chat history), and re-installing from App Store. Works on latest beta of macOS. So the issue might have been related to SwiftData migration to a beta version. A new SwiftData container fixed the issue, at least for now.
But on iOS 18 beta 4, I deleted the app and redownloaded from the app store. This worked. No more crashing.
Have never thought about this, but I tried the same. Deleting current installation (including all chat history), and re-installing from App Store. Works on latest beta of macOS. So the issue might have been related to SwiftData migration to a beta version. A new SwiftData container fixed the issue, at least for now.
I am getting the same error. How do you delete all the chat history, which files need to be deleted exactly? I tried deleting the Enchanted app in Applications, and reinstalling with App store but the problem persists?
Edit: found this in /Users/username/Library/Containers/subj.Enchanted/Data/Library/Application Support/
Hello @AugustDev,
I am testing the MacOS 15 & iOS 18 Betas and it seems that some things have changed which are causing a crash on launch.
Do you want me to send you crash logs anywhere?