I am also getting a similar repeating crash. When I add or create files to my local swift packages, Xcode constantly crashes with the following: Fatal error: Attempted to read an unowned reference but the object was already deallocated.
Typically the crash happens on saving the newly created file, and building. From the stack trace, it looks like the error is happening in the IDESwiftPackageBuildable.prebuildOperations. So any action that triggers a prebuild probably is causing the crash.
Once the crashing starts, it will keep crashing until I clean build.
Filed bug here: FB9989812
Post
Replies
Boosts
Views
Activity
Any update here on possible workarounds? I am seeing these crashes constantly in my app with SwiftUI. Really a horrible experience for our users - hard to believe core SwiftUI components could be this unstable. Filed feedback FB11800180
Date/Time: 2023-01-19 09:19:49.9921 -0500
Launch Time: 2023-01-19 09:11:40.5629 -0500
OS Version: iPhone OS 16.2 (20C65)
Release Type: User
Baseband Version: 2.21.00
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001aa0aae78
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [39631]
Triggered by Thread: 0
Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
Thread 0 name:
Thread 0 Crashed:
0 SwiftUI 0x00000001aa0aae78 ViewCache.item(data:) + 3484 (IncrementalLayout.swift:0)
1 SwiftUI 0x00000001aa692894 closure #2 in IncrementalStack<>.prefetch(children:edges:context:state:) + 64 (IncrementalLayout.swift:514)
2 SwiftUI 0x00000001ab531944 $s7SwiftUI6HVGrid33_31F43AFD49DC183BC0BAE157829FFC07LLPAAE5place8children6length13minorGeometry4emitySayAA24_IncrementalLayout_ChildVG_12CoreGraphics7CGFloatVSgSayAA0cN0ACLLVGyAK_So7CGPointVAA13_Pr... + 200
3 SwiftUI 0x00000001ab531bac protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyHGridLayout + 76
4 SwiftUI 0x00000001ab531b54 protocol witness for IncrementalStack.place(children:length:minorGeometry:emit:) in conformance LazyVGridLayout + 56
5 SwiftUI 0x00000001aa2637d8 $s7SwiftUI16IncrementalStackPA2A01_cD6_StateVyxG0E0RtzrlE8prefetch8children5edges7context5stateyAA01_C15Layout_ChildrenV_AA4EdgeO3SetVAA01_cK17_PlacementContextVAFtFAA09LazyVGridK033_31F43AFD49DC18... + 340 (IncrementalStack.swift:700)
6 SwiftUI 0x00000001aa26daa0 specialized closure #1 in closure #1 in IncrementalChildPrefetcher.updateValue() + 444 (<compiler-generated>:0)
7 SwiftUI 0x00000001aa26d688 specialized IncrementalChildPrefetcher.updateValue() + 216
8 SwiftUI 0x00000001aa492a08 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 44 (<compiler-generated>:0)
9 AttributeGraph 0x00000001c95f86f4 AG::Graph::UpdateStack::update() + 520 (ag-closure.h:109)
10 AttributeGraph 0x00000001c95f7f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424 (ag-graph-update.cc:714)
11 AttributeGraph 0x00000001c95f6c00 AG::Subgraph::update(unsigned int) + 844 (ag-subgraph.cc:734)
12 SwiftUI 0x00000001a9fbf4a8 GraphHost.flushTransactions() + 572 (GraphHost.swift:640)
13 SwiftUI 0x00000001aa087134 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
14 SwiftUI 0x00000001aa978108 static Update.dispatchActions() + 572 (<compiler-generated>:0)
15 SwiftUI 0x00000001a9fbade8 static Update.end() + 116 (Update.swift:58)
16 SwiftUI 0x00000001aaf447ac SystemScrollViewPrefetchState.commit(to:) + 344 (Update.swift:71)
17 SwiftUI 0x00000001ab1ae314 HostingScrollView._updateCycleIdle(until:) + 208 (HostingScrollView_PhoneTVWatch.swift:632)
18 SwiftUI 0x00000001ab1ae354 @objc HostingScrollView._updateCycleIdle(until:) + 40 (<compiler-generated>:0)
19 UIKitCore 0x00000001a8836544 ___UIUpdateCycleNotifyIdle_block_invoke + 612 (_UIUpdateCycleIdleScheduler.m:148)
20 libdispatch.dylib 0x00000001adbfb4b4 _dispatch_call_block_and_release + 32 (init.c:1518)
21 libdispatch.dylib 0x00000001adbfcfdc _dispatch_client_callout + 20 (object.m:560)
22 libdispatch.dylib 0x00000001adc0b7f4 _dispatch_main_queue_drain + 928 (inline_internal.h:2632)
23 libdispatch.dylib 0x00000001adc0b444 _dispatch_main_queue_callback_4CF + 44 (queue.c:7887)
24 CoreFoundation 0x00000001a667a6d8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
25 CoreFoundation 0x00000001a665c03c __CFRunLoopRun + 2036 (CFRunLoop.c:3147)
26 CoreFoundation 0x00000001a6660ec0 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
27 GraphicsServices 0x00000001e06b7368 GSEventRunModal + 164 (GSEvent.c:2196)
28 UIKitCore 0x00000001a8b5686c -[UIApplication _run] + 888 (UIApplication.m:3754)
29 UIKitCore 0x00000001a8b564d0 UIApplicationMain + 340 (UIApplication.m:5344)
30 Alinea 0x00000001023f6da0 main + 68 (AppDelegate.swift:28)
31 dyld 0x00000001c4e82960 start + 2528 (dyldMain.cpp:1170)
Same issue in iOS 16.3. Filed FB11800180 and in contact with DTS, who said that the the SwiftUI team has identified the underlying cause of the regression. But there is still no fix available. Very frustrating...
Full crash log below. Hopefully reveals some insight I have missed. Thank you!
2023-01-25_12-58-09.8491_-0500-812cfda00fb784984b06a6a8253ede8d396a7dcf.crash
I have started having this same issue occur with my app in Xcode 15.3:
== PREVIEW UPDATE ERROR:
HumanReadableSwiftError
BuildError: failedToGenerateThunkInfo(could not generate preview info: noTargetBuildGraph)
Is anyone experiencing the same problems? My preview, which lives in a SPM package, works totally fine in Xcode 15.2, but fails in Xcode 15.3. Any ideas for how to fix it? I've tried deleting DerivedData, resetting package caches, clean building.
So frustrating seeing these regression issues popping up still. Filed: FB13678356
To add a bit more information that could hopefully help: I also tried creating a brand new swift package in my project with no dependencies to my other packages and I encountered the same error. I updated my FB with full diagnostic report as well so that hopefully will illuminate the error.
And again:
Deleted DerivedData folder
Reset Package Caches
Clean
Build
No luck unfortunately! Any insight would be much appreciated.
Updated the Feedback with a small example and was able to find a fix! It looks like the error is happening because of a library I use that uses macros. I eventually found a warning in the project logs and had to accept the above message after which it started working again.
Would note, not having enabled that macros plugin caused every preview in every package to stop working without any clear error message as to why! So glad I was able to get things working again though. Shoutout the guys at http://pointfree.co for taking a look!
Any reason why you think the issue happens even if the dependency is unused or in a completely different package? For example, when I added a completely fresh swift package to my project that has no dependency on any other package in my system, the error still happened and previews in the new package fail as well.
Weird that it only causes a problem in previews though, no? It's surprising that I would be able to build the app on the device at all if that was the case. Do previews do the build that differently?
Full crash report below! Also filed FB15236099
Thanks in advance for the help!
concurrency_crash_report.txt
Hmmm... Looked at alamofire and looks like someone has reported a similar issue. https://github.com/Alamofire/Alamofire/issues/3896
They seem to be saying that it's a bug in the swift runtime however: https://github.com/swiftlang/swift/issues/75952
Hopefully a fix is coming very soon from Apple, since it doesn't look like a workaround is available.