Post

Replies

Boosts

Views

Activity

Invalid memory pointer crash: cannot figure out cause
Hi there! I'm one year into iOS development, and can usually figure out the cause of a crash. However, I've been bumping my head against this one for a while now. Invalid memory pointer crash According to this article, the crash (EXC_BAD_ACCESS) happens due to an invalid memory pointer. When I use the atos command to symbolicate the crash report, the line where the crash happens in my app (see line 39 in the full stack trace below) is simply the very first line in MyApp that extends App (annotated with @main) -- but there's no code on that line. It seems like the error is happening somewhere with UIKit's UIViewController but I can't seem to figure it out. Could be relevant code I do have the following class in my app, which helps with hiding the tab bar I use when another view is opened. It might be relevant: struct HideTabBar: UIViewControllerRepresentable { var callback: (UITabBar) -> Void private let proxyController = ViewController() func makeUIViewController(context: UIViewControllerRepresentableContext<HideTabBar>) -> UIViewController { proxyController.callback = callback return proxyController } func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<HideTabBar>) { } typealias UIViewControllerType = UIViewController private class ViewController: UIViewController { var callback: (UITabBar) -> Void = { _ in } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let tabBar = self.tabBarController { self.callback(tabBar.tabBar) } } } } Full stack trace: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010 Exception Codes: 0x0000000000000001, 0x0000000000000010 VM Region Info: 0x10 is not in any region. Bytes before following region: 4363845616 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> Termination Reason: SIGNAL 11 Segmentation fault: 11 Terminating Process: exc handler [664] Triggered by Thread: 0 Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libobjc.A.dylib 0x19205fc20 objc_msgSend + 32 1 UIKitCore 0x19c697a68 -[UIViewController dealloc] + 860 2 UIKitCore 0x19c863c80 -[UINavigationController dealloc] + 296 3 UIKitCore 0x19c863b34 -[_UISplitViewControllerColumnContents .cxx_destruct] + 44 4 libobjc.A.dylib 0x192061acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 5 libobjc.A.dylib 0x192060f00 objc_destructInstance + 80 6 libobjc.A.dylib 0x192060ea4 _objc_rootDealloc + 80 7 CoreFoundation 0x19a0fc730 cow_cleanup + 164 8 CoreFoundation 0x19a0fec80 -[__NSDictionaryM dealloc] + 148 9 libobjc.A.dylib 0x192061acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 10 libobjc.A.dylib 0x192060f00 objc_destructInstance + 80 11 libobjc.A.dylib 0x192060ea4 _objc_rootDealloc + 80 12 UIKitCore 0x19c8f4a54 -[UISplitViewControllerPanelImpl dealloc] + 100 13 libobjc.A.dylib 0x192061acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 14 libobjc.A.dylib 0x192060f00 objc_destructInstance + 80 15 libobjc.A.dylib 0x192060ea4 _objc_rootDealloc + 80 16 UIKitCore 0x19c457730 -[UIResponder dealloc] + 124 17 UIKitCore 0x19c697ba0 -[UIViewController dealloc] + 1172 18 libobjc.A.dylib 0x192060df4 AutoreleasePoolPage::releaseUntil(objc_object**) + 212 19 libobjc.A.dylib 0x192060c80 objc_autoreleasePoolPop + 260 20 UIKitCore 0x19c4315ec -[_UIAfterCACommitBlock run] + 92 21 UIKitCore 0x19c43149c -[_UIAfterCACommitQueue flush] + 164 22 UIKitCore 0x19c4313b4 _runAfterCACommitDeferredBlocks + 496 23 UIKitCore 0x19c430fec _cleanUpAfterCAFlushAndRunDeferredBlocks + 80 24 UIKitCore 0x19c430efc _UIApplicationFlushCATransaction + 72 25 UIKitCore 0x19c42e660 _UIUpdateSequenceRun + 84 26 UIKitCore 0x19c42e2a4 schedulerStepScheduledMainSection + 172 27 UIKitCore 0x19c42f148 runloopSourceCallback + 92 28 CoreFoundation 0x19a14b834 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 29 CoreFoundation 0x19a14b7c8 __CFRunLoopDoSource0 + 176 30 CoreFoundation 0x19a149298 __CFRunLoopDoSources0 + 244 31 CoreFoundation 0x19a148484 __CFRunLoopRun + 828 32 CoreFoundation 0x19a147cd8 CFRunLoopRunSpecific + 608 33 GraphicsServices 0x1deb951a8 GSEventRunModal + 164 34 UIKitCore 0x19c781ae8 -[UIApplication _run] + 888 35 UIKitCore 0x19c835d98 UIApplicationMain + 340 36 SwiftUI 0x19e33c294 0x19df48000 + 4145812 37 SwiftUI 0x19e2e8860 0x19df48000 + 3803232 38 SwiftUI 0x19e2f461c 0x19df48000 + 3851804 39 MyApp 0x1041f8690 0x1041b0000 + 296592 40 dyld 0x1bd91f154 start + 2356
0
1
201
Oct ’24
Problem loading icon for ApplicationToken with Label
After the Screen Time permissions have been provided by the user, when I create a label with the user's selected ApplicationToken or CategoryToken, it's often (not always!) show like this: I instantiate the label like this, where app is an ApplicationToken or CategoryToken: Label(app)     .labelStyle(.iconOnly) After the app is killed and reloaded, the icons show up fine. Any suggestions on how to fix this? Is this an issue with the Screen Time API, or am I instantiating the label in the wrong way?
9
1
1.6k
Jan ’23