Code Diagnostics

RSS for tag

Enable runtime checks to detect and avoid bugs in your code using Code Diagnostics.

Code Diagnostics Documentation

Posts under Code Diagnostics tag

10 Posts
Sort by:
Post not yet marked as solved
0 Replies
51 Views
Hello, my production app is experiencing some crashes according to app store analytics. I cannot seem to reproduce it. According to Xcode Orginzer the app is crashing 10 SwiftUI 0x000000018ec372a0 PlatformViewHost.updateNestedHosts(_:colorSchemeChanged:) + 332 (PlatformViewHost.swift:699) Distributor ID: com.apple.AppStore Hardware Model: iPhone13,4 Version: 2.0.3 (86) AppStoreTools: 15E204 AppVariant: 1:iPhone13,4:16 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] OS Version: iPhone OS 17.4.1 (21E236) Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 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 libsystem_kernel.dylib 0x00000001d1bd6974 __pthread_kill + 8 (:-1) 1 libsystem_pthread.dylib 0x00000001e56590ec pthread_kill + 268 (pthread.c:1717) 2 libsystem_c.dylib 0x0000000191627c14 __abort + 136 (abort.c:159) 3 libsystem_c.dylib 0x0000000191627b8c abort + 192 (abort.c:126) 4 libswiftCore.dylib 0x000000018832a690 swift::fatalErrorv(unsigned int, char const*, char*) + 136 (Errors.cpp:387) 5 libswiftCore.dylib 0x000000018832a6b0 swift::fatalError(unsigned int, char const*, ...) + 32 (Errors.cpp:395) 6 libswiftCore.dylib 0x0000000188324a08 getNonNullSrcObject(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*) + 256 (DynamicCast.cpp:144) 7 libswiftCore.dylib 0x0000000188326510 tryCastToObjectiveCClass(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InPro... + 88 (DynamicCast.cpp:510) 8 libswiftCore.dylib 0x0000000188324068 tryCast(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*&, sw... + 992 (DynamicCast.cpp:2281) 9 libswiftCore.dylib 0x0000000188323b14 swift_dynamicCast + 208 (CompatibilityOverrideRuntime.def:109) 10 SwiftUI 0x000000018ec372a0 PlatformViewHost.updateNestedHosts(_:colorSchemeChanged:) + 332 (PlatformViewHost.swift:699) 11 SwiftUI 0x000000018ec36bf4 PlatformViewHost.updateEnvironment(_:viewPhase:) + 412 (PlatformViewHost.swift:690) 12 SwiftUI 0x000000018ec37bf8 PlatformViewHost.init(_:host:environment:viewPhase:importer:) + 808 (PlatformViewHost.swift:132) 13 SwiftUI 0x000000018ec36cf8 PlatformViewHost.__allocating_init(_:host:environment:viewPhase:importer:) + 92 (PlatformViewHost.swift:0) 14 SwiftUI 0x000000018ec0132c closure #1 in closure #1 in closure #4 in closure #1 in PlatformViewChild.updateValue() + 444 (PlatformViewRepresentable.swift:559) 15 SwiftUI 0x000000018ec06c58 partial apply for closure #1 in closure #1 in closure #4 in closure #1 in PlatformViewChild.updateValue() + 24 (<compiler-generated>:0) 16 SwiftUI 0x000000018ea26910 RepresentableContextValues.asCurrent<A>(do:) + 156 (RepresentableContextValues.swift:43) 17 SwiftUI 0x000000018ec01124 closure #1 in closure #4 in closure #1 in PlatformViewChild.updateValue() + 176 (PlatformViewRepresentable.swift:558) 18 SwiftUI 0x000000018ec0104c closure #4 in closure #1 in PlatformViewChild.updateValue() + 128 (PlatformViewRepresentable.swift:557) 19 SwiftUI 0x000000018ec06b2c partial apply for closure #4 in closure #1 in PlatformViewChild.updateValue() + 24 (<compiler-generated>:0) 20 SwiftUI 0x000000018de7b7d0 closure #1 in _withObservation<A>(do:) + 44 (ObservationUtils.swift:26) 21 SwiftUI 0x000000018ec06b50 partial apply for closure #1 in _withObservation<A>(do:) + 24 (<compiler-generated>:0) 22 libswiftCore.dylib 0x0000000187fd0068 withUnsafeMutablePointer<A, B>(to:_:) + 28 (LifetimeManager.swift:82) 23 SwiftUI 0x000000018ebffbdc closure #1 in PlatformViewChild.updateValue() + 3040 (PlatformViewRepresentable.swift:556) 24 SwiftUI 0x000000018d5ecbf8 partial apply for implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 32 (<compiler-generated>:0) 25 AttributeGraph 0x00000001b2150240 AG::Graph::UpdateStack::update() + 512 (ag-graph-update.cc:578) 26 AttributeGraph 0x00000001b2146f38 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424 (ag-graph-update.cc:719) 27 AttributeGraph 0x00000001b2146810 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 720 (ag-graph.cc:1429)
Posted
by
Post not yet marked as solved
1 Replies
61 Views
i am attaching crash logs would be really appreciated for any kind of help :) Review Environment Submission ID: f7cb438c-5784-44e7-abcf-4a787c9398ff Review date: April 30, 2024 Version reviewed: 1.0 Guideline 2.1 - Performance - App Completeness We were unable to review your app as it crashed on launch. We have attached detailed crash logs to help troubleshoot this issue. Review device details: Device type: iPad Air (5th generation) and iPhone 13 mini OS version: iOS 17.4.1 crashlog-639DEF1C-6DE4-437F-BEFE-E0DA6F31FFD8.txt crashlog-4EC7F1AA-18A9-4057-B1AD-9677FEA6981F.txt
Posted
by
Post not yet marked as solved
0 Replies
140 Views
After upgrading to iOS 17, Thread Performance Checker is complaining of priority inversion when converting a CVPixelBuffer to UIImage through a CIImage instance. It might be a false-positive or an issue? - (UIImage *)imageForSampleBuffer:(CMSampleBufferRef)sampleBuffer andOrientation:(UIImageOrientation)orientation { CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixelBuffer]; UIImage *uiImage = [UIImage imageWithCIImage:ciImage]; NSData *data = UIImageJPEGRepresentation(uiImage, 90); } The code snippet above, when running in a thread set to the default priority results in the message below: Thread Performance Checker: Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions PID: 1188, TID: 723209 Backtrace ================================================================= 3 AGXMetalG14 0x0000000235c77cc8 1FEF1F89-B467-37B0-86F8-E05BC8A2A629 + 2927816 4 AGXMetalG14 0x0000000235ccd784 1FEF1F89-B467-37B0-86F8-E05BC8A2A629 + 3278724 5 AGXMetalG14 0x0000000235ccf6a4 1FEF1F89-B467-37B0-86F8-E05BC8A2A629 + 3286692 6 MetalTools 0x000000022f758b68 E712D983-01AD-3FE5-AB66-E00ABF76CD7F + 568168 7 CoreImage 0x00000001a7c0e580 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 267648 8 CoreImage 0x00000001a7d0cc08 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 1309704 9 CoreImage 0x00000001a7c0e2e0 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 266976 10 CoreImage 0x00000001a7c0e1d0 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 266704 11 libdispatch.dylib 0x0000000105e4a7bc _dispatch_client_callout + 20 12 libdispatch.dylib 0x0000000105e5be24 _dispatch_lane_barrier_sync_invoke_and_complete + 176 13 CoreImage 0x00000001a7c0a784 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 251780 14 CoreImage 0x00000001a7c0a46c 3D2AC243-0880-3BA9-BBF3-A214454875E0 + 250988 15 libdispatch.dylib 0x0000000105e5b764 _dispatch_block_async_invoke2 + 148 16 libdispatch.dylib 0x0000000105e4a7bc _dispatch_client_callout + 20 17 libdispatch.dylib 0x0000000105e5266c _dispatch_lane_serial_drain + 832 18 libdispatch.dylib 0x0000000105e5343c _dispatch_lane_invoke + 460 19 libdispatch.dylib 0x0000000105e524a4 _dispatch_lane_serial_drain + 376 20 libdispatch.dylib 0x0000000105e5343c _dispatch_lane_invoke + 460 21 libdispatch.dylib 0x0000000105e60404 _dispatch_root_queue_drain_deferred_wlh + 328 22 libdispatch.dylib 0x0000000105e5fa38 _dispatch_workloop_worker_thread + 444 23 libsystem_pthread.dylib 0x00000001f35a4f20 _pthread_wqthread + 288 24 libsystem_pthread.dylib 0x00000001f35a4fc0 start_wqthread + 8
Posted
by
Post marked as solved
4 Replies
275 Views
Dear all, I have the following code in a view: import SwiftUI struct RosaView: View { @State var rosa: [Rosa] = Rosa.testRosa() @State private var apriNuovoGiocatore = false @State var stagione: String = "2023/2024" var rosaFiltrata: [Rosa] { Rosa.testRosa().filter { $0.stagione == stagione } } @State private var selezioneGiocatore: Rosa.ID? = nil @State private var ordine = [KeyPathComparator(\Rosa.ruoloGiocatore)] var body: some View { VStack(alignment: .leading) { Text("Stagione: \(stagione)") .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/) .font(.headline) .foregroundColor(/*@START_MENU_TOKEN@*/.blue/*@END_MENU_TOKEN@*/) .padding() Table(rosaFiltrata, selection: $selezioneGiocatore, sortOrder: $ordine) { TableColumn(Text("Nome").foregroundStyle(.blue), value: \.nomeGiocatore) TableColumn(Text("Cognome").foregroundStyle(.blue), value: \.cognomeGiocatore) TableColumn(Text("Ruolo").foregroundStyle(.blue), value: \.ruoloGiocatore) TableColumn(Text("Data di nascita").foregroundStyle(.blue), value: \.nascitaGiocatore) TableColumn(Text("Età").foregroundStyle(.blue)) { Rosa in Text("\(Rosa.etàGiocatore)") } } } .frame(width: 900, height: 400) .toolbar { Button { apriNuovoGiocatore = true } label: { Image(systemName: "person.badge.plus") .foregroundColor(/*@START_MENU_TOKEN@*/.blue/*@END_MENU_TOKEN@*/) } .sheet(isPresented: $apriNuovoGiocatore, content: { nuovoGiocatore() }) } .navigationTitle("Rosa") } } struct nuovoGiocatore: View { @Environment(\.dismiss) var dismiss @State var nomeNuovoGiocatore: String @State var cognomeNuovoGiocatore: String @State var nascitaNuovoGiocatore: String @State var ruoloNuovoGiocatore: String @State var etàNuovoGiocatore: Int var body: some View { NavigationStack { Form { TextField("Nome:", text: $nomeNuovoGiocatore) TextField("Cognome:", text: $cognomeNuovoGiocatore) } .navigationTitle("Nuovo giocatore") .toolbar { Button("Cancel") { dismiss() } Button("Aggiungi giocatore") { let nuovoGiocatore = Rosa(stagione: "2023/2024", nomeGiocatore: nomeNuovoGiocatore, cognomeGiocatore: cognomeNuovoGiocatore, nascitaGiocatore: nascitaNuovoGiocatore, etàGiocatore: etàNuovoGiocatore, ruoloGiocatore: ruoloNuovoGiocatore) Rosa.testRosa().append(nuovoGiocatore) dismiss() } } } } } #Preview { RosaView() } On this, I'm getting a strange error which is "Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)" in the "var body: some View" statement of the view "nuovoGiocatore". How can I avoid it? Am I doing something wrong in the coding? Thanks, A.
Posted
by
Post not yet marked as solved
0 Replies
356 Views
I am running xctests from command line on XCode 15.2 on iOS 17.2 simulators. As per WWDC2021 video on Memory issues, I am passing `-enablePerformanceTestsDiagnostics Yes' in following xcodebuild command. xcodebuild test -project project_name.xcodeproj -scheme test-scheme -destination 'platform=iOS Simulator,name=iPhone 15 Pro' -enablePerformanceTestsDiagnostics YES Final logs before test results: Tests-Runner(16873) MallocStackLogging: stack logs deleted from /private/tmp/stack-logs.16873.10148c000.Tests-Runner.M6gFw .xcresults is generated but no memgraph file is attached along with it.
Posted
by
Post marked as solved
2 Replies
534 Views
Consider the following program, memory-leak.c: #include <stdlib.h> void *p; int main() { p = malloc(7); p = 0; // The memory is leaked here. return 0; } If I compile this with clang memory-leak.c and test the output with the built-in MacOS memory leak detector leaks using leaks -quiet -atExit -- ./a.out, I get (partly) the following output: 1 leak for 16 total leaked bytes. However, if I remove the 'leaking' line like so: #include <stdlib.h> void *p; int main() { p = malloc(7); return 0; } Compiling this file and again running leaks now (partly) returns: 0 leaks for 0 total leaked bytes. The man page for leaks shows that it is only un-reachable memory that is considered a leak. Is there a configuration to detect un-free'd reachablemalloc segments?
Posted
by
Post not yet marked as solved
1 Replies
561 Views
xCode requested that I send in a bug report. Failed to produce diagnostic for expression, please submit a bug report. I can't manage to paste the image here, so I'll just state that the latest Xcode, 15.1 seems to produce spurious error messages on screen which usually manage to disappear over time. I'll send this in to feedback with the sysdiagnose report. It's a major pain.
Posted
by
Post not yet marked as solved
2 Replies
764 Views
Our CI pipeline produces .xcresult bundles that allow developers to diagnose failures by opening them in Xcode. If the test crashes, we used to be able to open the diagnostic folders and inspect the raw test logs. As of Xcode 15, that option is no longer available. I know the Diagnostic data is there because I can view it with Xcode 14. Am I just missing something in the Xcode 15 UI? Or has the capability to browse the Diagnostics actually been removed?
Posted
by
Post not yet marked as solved
1 Replies
608 Views
Hi folks! My iOS app has the MetricKit integration, and I'm processing the reports on my server. While looking at some MXCrashDiagnostic reports, I saw certain reports that has threadAttributed property as true, but callStackRootFrames is just an empty array. So the report looks like the following example "callStacks" : [ { "threadAttributed" : true, "callStackRootFrames" : [ ] }, // ... // other callstacks where threadAttributed is false // but callStackRootFrames is not empty ] Looking at the documentation I can see threadAttributed is used to determine if the crash/exception occurred in this crash. So I can't understand how callStackRootFrames can be empty when threadAttributed is true. Is this a bug or an expected behavior? Also, is there a case where the crash/exception report does not have any callstack with threadAttributed as true? From the definition, it feels like there should always be exactly one attributed thread on each crash report. Thanks for the help!
Post marked as solved
3 Replies
3.7k Views
Hello I have a problem with xCode, I have this error : Cannot find « string » in scope. Thank you so much for your help Photos: My code: // //  AuthviewModel.swift //  iSpeak // //  Created by Sayan on 21.11.22. // import Foundation import Firebase class AuthViewModel: ObservableObject {     var manager = FirebaseManager.shared          @Published var isFinishedConnecting: Bool = false     @Published var isAuth: Bool = false     @Published var showError: Bool = false          var errorString: String = ""     var datas: [String: Any] = [:]          var auth: Auth {         return manager.auth     }          init() {         observeAuthentication()     }          func observeAuthentication() {         auth.addStateDidChangeListener(handleChangeListener)     }          func handleChangeListener(auth: Auth, user: User?) {         self.isFinishedConnecting = true         self.isAuth = user != nil     }          func signIn(email: String, password: String) {         guard checkValue(_string: email, value: "adresse email") else { return }         guard checkValue(_string: password, value: "Mot de passe") else { return }              }          func createUser() {              }          func checkValue(_string: String, value: String) -> Bool {         let isNotEmpty = string != ""         self.errorString = !isNotEmpty ? "" : "Merci d'entrer (value) pour continuer"         self.showError = !isNotEmpty         return isNotEmpty     } }
Posted
by