【发布时间】:2022-01-08 07:59:06
【问题描述】:
我已尝试完全按照 Apple 网站 (https://developer.apple.com/documentation/vision/recognizing_text_in_images) 上的说明实施 OCR,但在尝试执行 OCR 时出现一系列指针错误。错误已在 Xcode 中标记为 Thread 1: EXC_BAD_ACCESS (code=1, address=0x17dfe3ff0) 或 Thread 1: De-allocation of unallocated memory。
我的问题是这样的:
- 为什么我从 Apple 自己的软件包中收到一个指针错误?我错过的设置有什么问题吗?
- (次要观点)为什么这会使我的应用程序崩溃,而不是被优雅地捕获?
我认为这可能与 UIImage 在 VNImageRequestHandler 得到它之前被取消分配有关?我有一个单独的相机框架,用于拍摄和裁剪照片并返回图像,所以图像可能正在被取消分配或被认为超出范围?我以前见过这个错误,它在一夜之间就消失了,但我宁愿不只是祈祷它消失!
编辑:根据 cmets 中的建议,我关闭了 Address Sanitizer,它似乎又可以工作了。不将此标记为已解决,因为我希望我的代码在打开调试工具时不要中断...
@available(iOS 13.0, *)
class func recogniseText(inImage: UIImage, completionHandler: @escaping (_ recognisedText: String?) -> Void){
guard let cgImage = inImage.cgImage else{
return completionHandler(nil)
}
let requestHandler = VNImageRequestHandler(cgImage: cgImage)
let ocrRequest = VNRecognizeTextRequest { (request, error) in
guard let observations = request.results as? [VNRecognizedTextObservation] else{
return completionHandler(nil)
}
let recognizedStrings = observations.compactMap { observation in
// Return the string of the top VNRecognizedText instance.
observation.topCandidates(1).first?.string
}
completionHandler(recognizedStrings.joined(separator: "\n"))
}
ocrRequest.recognitionLevel = .accurate
ocrRequest.recognitionLanguages = ["en-GB"]
ocrRequest.usesLanguageCorrection = false
do {
try requestHandler.perform([ocrRequest]) // Error is thrown here
} catch {
completionHandler(nil)
}
}
日志如下:
=================================================================
==1979==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00017b400000 in thread T0
#0 0x1033df438 in wrap_free+0x8c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438)
#1 0x195b3d0f4 in <redacted>+0x3c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xf0f4)
#2 0x195b40470 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0x12470)
#3 0x195b380b0 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xa0b0)
#4 0x199aebf0c in <redacted>+0x6c (/usr/lib/libobjc.A.dylib:arm64+0x6f0c)
#5 0x199ae8f04 in objc_destructInstance+0x54 (/usr/lib/libobjc.A.dylib:arm64+0x3f04)
#6 0x199af1db8 in _objc_rootDealloc+0x30 (/usr/lib/libobjc.A.dylib:arm64+0xcdb8)
#7 0x199aeb584 in <redacted>+0xc0 (/usr/lib/libobjc.A.dylib:arm64+0x6584)
#8 0x199ae7dec in objc_autoreleasePoolPop+0xc8 (/usr/lib/libobjc.A.dylib:arm64+0x2dec)
#9 0x1a47bfb80 in <redacted>+0x100 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4b80)
#10 0x1a47bfa3c in <redacted>+0x30 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4a3c)
#11 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
#12 0x1a482d6dc in <redacted>+0x28 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x726dc)
#13 0x10444d600 in _dispatch_block_sync_invoke+0x68 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x9600)
#14 0x104449f90 in _dispatch_client_callout+0xc (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x5f90)
#15 0x104459634 in _dispatch_lane_barrier_sync_invoke_and_complete+0x74 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x15634)
#16 0x10444eb18 in _dispatch_sync_block_with_privdata+0x188 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0xab18)
#17 0x1a47c4eac in <redacted>+0x19c (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9eac)
#18 0x1a499251c in <redacted>+0x220 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x1d751c)
#19 0x1a47bd79c in <redacted>+0x2c0 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x279c)
#20 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
#21 0x1a47c4514 in <redacted>+0x200 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9514)
#22 0x1a47c2a9c in <redacted>+0x1b4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7a9c)
#23 0x1a47c2878 in <redacted>+0xb4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7878)
#24 0x100fd69b4 in static ---.---.recogniseText(inImage: __C.UIImage, completionHandler: (Swift.Optional<Swift.String>) -> ()) -> ()+0x890 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1001ea9b4)
#25 0x100ee3458 in ---.---View.---Controller(_: ---.---Controller, didFinishScanningWithResults: ---.ImageScannerResults) -> ()+0x4b4 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000f7458)
#26 0x100ee68bc in protocol witness for ---.ImageScannerControllerDelegate.imageScannerController(_: ---.ImageScannerController, didFinishScanningWithResults: ---.ImageScannerResults) -> () in conformance ---.IdentityGetStartedView : ---.ImageScannerControllerDelegate in ---+0x8 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000fa8bc)
#27 0x103f0deb0 in ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x49c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/---:arm64+0x4deb0)
#28 0x103f0df40 in @objc ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x20 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/---:arm64+0x4df40)
#29 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
#30 0x18537386c in <redacted>+0xac (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x75b86c)
#31 0x18535e6d0 in <redacted>+0x20 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x7466d0)
#32 0x18535e584 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x746584)
#33 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
#34 0x1851d67d4 in <redacted>+0x78 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x5be7d4)
#35 0x184f69d70 in <redacted>+0x158 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351d70)
#36 0x184f69dc0 in <redacted>+0x1a8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351dc0)
#37 0x18527b2e4 in <redacted>+0x210 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x6632e4)
#38 0x184d7bbf8 in <redacted>+0x4c8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x163bf8)
#39 0x184dabc54 in <redacted>+0x1124 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x193c54)
#40 0x184f4ee70 in <redacted>+0x37c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x336e70)
#41 0x184d8070c in <redacted>+0x1fb8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x16870c)
#42 0x184d75658 in <redacted>+0x1a58 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x15d658)
#43 0x184d7a9e8 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x1629e8)
#44 0x18296620c in <redacted>+0x14 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xb220c)
#45 0x182976234 in <redacted>+0xc8 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xc2234)
#46 0x1828b95d4 in <redacted>+0xfc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x55d4)
#47 0x1828bea04 in <redacted>+0x2fc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xaa04)
#48 0x1828d1d78 in CFRunLoopRunSpecific+0x238 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x1dd78)
#49 0x19cb4699c in GSEventRunModal+0x9c (/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices:arm64+0x199c)
#50 0x185104058 in <redacted>+0x434 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x4ec058)
#51 0x184e99cdc in UIApplicationMain+0x7e8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x281cdc)
#52 0x101212988 in main+0x3c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x100426988)
#53 0x102f6018c (/usr/lib/dyld:arm64+0x1818c)
Address 0x00017b400000 is a wild pointer.
SUMMARY: AddressSanitizer: bad-free (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438) in wrap_free+0x8c
2021-12-01 15:31:56.039013+0000 ---[1979:545450] =================================================================
2021-12-01 15:31:56.039144+0000 ---[1979:545450] ==1979==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00017b400000 in thread T0
2021-12-01 15:31:56.039222+0000 ---[1979:545450] #0 0x1033df438 in wrap_free+0x8c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438)
2021-12-01 15:31:56.039287+0000 ---[1979:545450] #1 0x195b3d0f4 in <redacted>+0x3c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xf0f4)
2021-12-01 15:31:56.039350+0000 ---[1979:545450] #2 0x195b40470 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0x12470)
2021-12-01 15:31:56.039410+0000 ---[1979:545450] #3 0x195b380b0 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xa0b0)
2021-12-01 15:31:56.039472+0000 ---[1979:545450] #4 0x199aebf0c in <redacted>+0x6c (/usr/lib/libobjc.A.dylib:arm64+0x6f0c)
2021-12-01 15:31:56.039539+0000 ---[1979:545450] #5 0x199ae8f04 in objc_destructInstance+0x54 (/usr/lib/libobjc.A.dylib:arm64+0x3f04)
2021-12-01 15:31:56.040035+0000 ---[1979:545450] #6 0x199af1db8 in _objc_rootDealloc+0x30 (/usr/lib/libobjc.A.dylib:arm64+0xcdb8)
2021-12-01 15:31:56.040115+0000 ---[1979:545450] #7 0x199aeb584 in <redacted>+0xc0 (/usr/lib/libobjc.A.dylib:arm64+0x6584)
2021-12-01 15:31:56.040179+0000 ---[1979:545450] #8 0x199ae7dec in objc_autoreleasePoolPop+0xc8 (/usr/lib/libobjc.A.dylib:arm64+0x2dec)
2021-12-01 15:31:56.040240+0000 ---[1979:545450] #9 0x1a47bfb80 in <redacted>+0x100 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4b80)
2021-12-01 15:31:56.040305+0000 ---[1979:545450] #10 0x1a47bfa3c in <redacted>+0x30 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4a3c)
2021-12-01 15:31:56.040366+0000 ---[1979:545450] #11 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
2021-12-01 15:31:56.040429+0000 ---[1979:545450] #12 0x1a482d6dc in <redacted>+0x28 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x726dc)
2021-12-01 15:31:56.040575+0000 ---[1979:545450] #13 0x10444d600 in _dispatch_block_sync_invoke+0x68 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x9600)
2021-12-01 15:31:56.040639+0000 ---[1979:545450] #14 0x104449f90 in _dispatch_client_callout+0xc (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x5f90)
2021-12-01 15:31:56.040704+0000 ---[1979:545450] #15 0x104459634 in _dispatch_lane_barrier_sync_invoke_and_complete+0x74 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x15634)
2021-12-01 15:31:56.041072+0000 ---[1979:545450] #16 0x10444eb18 in _dispatch_sync_block_with_privdata+0x188 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0xab18)
2021-12-01 15:31:56.041140+0000 ---[1979:545450] #17 0x1a47c4eac in <redacted>+0x19c (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9eac)
2021-12-01 15:31:56.041203+0000 ---[1979:545450] #18 0x1a499251c in <redacted>+0x220 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x1d751c)
2021-12-01 15:31:56.041434+0000 ---[1979:545450] #19 0x1a47bd79c in <redacted>+0x2c0 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x279c)
2021-12-01 15:31:56.041497+0000 ---[1979:545450] #20 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
2021-12-01 15:31:56.041555+0000 ---[1979:545450] #21 0x1a47c4514 in <redacted>+0x200 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9514)
2021-12-01 15:31:56.041636+0000 ---[1979:545450] #22 0x1a47c2a9c in <redacted>+0x1b4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7a9c)
2021-12-01 15:31:56.041699+0000 ---[1979:545450] #23 0x1a47c2878 in <redacted>+0xb4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7878)
2021-12-01 15:31:56.041758+0000 ---[1979:545450] #24 0x100fd69b4 in static ---.IdentityDocumentController.recogniseText(inImage: __C.UIImage, completionHandler: (Swift.Optional<Swift.String>) -> ()) -> ()+0x890 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1001ea9b4)
2021-12-01 15:31:56.041924+0000 ---[1979:545450] #25 0x100ee3458 in ---.IdentityGetStartedView.imageScannerController(_: ---.ImageScannerController, didFinishScanningWithResults: ---.ImageScannerResults) -> ()+0x4b4 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000f7458)
2021-12-01 15:31:56.041993+0000 ---[1979:545450] #26 0x100ee68bc in protocol witness for ---.ImageScannerControllerDelegate.imageScannerController(_: ---.ImageScannerController, didFinishScanningWithResults: ---.ImageScannerResults) -> () in conformance ---.IdentityGetStartedView : ---.ImageScannerControllerDelegate in ---+0x8 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000fa8bc)
2021-12-01 15:31:56.042248+0000 ---[1979:545450] #27 0x103f0deb0 in ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x49c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/---:arm64+0x4deb0)
2021-12-01 15:31:56.042315+0000 ---[1979:545450] #28 0x103f0df40 in @objc ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x20 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/PIOScanningKit:arm64+0x4df40)
2021-12-01 15:31:56.042379+0000 ---[1979:545450] #29 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
2021-12-01 15:31:56.042761+0000 ---[1979:545450] #30 0x18537386c in <redacted>+0xac (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x75b86c)
2021-12-01 15:31:56.042861+0000 ---[1979:545450] #31 0x18535e6d0 in <redacted>+0x20 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x7466d0)
2021-12-01 15:31:56.042927+0000 ---[1979:545450] #32 0x18535e584 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x746584)
2021-12-01 15:31:56.042989+0000 ---[1979:545450] #33 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
2021-12-01 15:31:56.043052+0000 ---[1979:545450] #34 0x1851d67d4 in <redacted>+0x78 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x5be7d4)
2021-12-01 15:31:56.043113+0000 ---[1979:545450] #35 0x184f69d70 in <redacted>+0x158 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351d70)
2021-12-01 15:31:56.043796+0000 ---[1979:545450] #36 0x184f69dc0 in <redacted>+0x1a8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351dc0)
2021-12-01 15:31:56.043858+0000 ---[1979:545450] #37 0x18527b2e4 in <redacted>+0x210 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x6632e4)
2021-12-01 15:31:56.043916+0000 ---[1979:545450] #38 0x184d7bbf8 in <redacted>+0x4c8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x163bf8)
2021-12-01 15:31:56.043980+0000 ---[1979:545450] #39 0x184dabc54 in <redacted>+0x1124 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x193c54)
2021-12-01 15:31:56.044110+0000 ---[1979:545450] #40 0x184f4ee70 in <redacted>+0x37c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x336e70)
2021-12-01 15:31:56.044359+0000 ---[1979:545450] #41 0x184d8070c in <redacted>+0x1fb8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x16870c)
2021-12-01 15:31:56.044800+0000 ---[1979:545450] #42 0x184d75658 in <redacted>+0x1a58 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x15d658)
2021-12-01 15:31:56.045033+0000 ---[1979:545450] #43 0x184d7a9e8 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x1629e8)
2021-12-01 15:31:56.045255+0000 ---[1979:545450] #44 0x18296620c in <redacted>+0x14 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xb220c)
2021-12-01 15:31:56.045481+0000 ---[1979:545450] #45 0x182976234 in <redacted>+0xc8 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xc2234)
2021-12-01 15:31:56.046587+0000 ---[1979:545450] #46 0x1828b95d4 in <redacted>+0xfc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x55d4)
2021-12-01 15:31:56.046847+0000 ---[1979:545450] #47 0x1828bea04 in <redacted>+0x2fc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xaa04)
2021-12-01 15:31:56.047586+0000 ---[1979:545450] #48 0x1828d1d78 in CFRunLoopRunSpecific+0x238 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x1dd78)
2021-12-01 15:31:56.047851+0000 ---[1979:545450] #49 0x19cb4699c in GSEventRunModal+0x9c (/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices:arm64+0x199c)
2021-12-01 15:31:56.048791+0000 ---[1979:545450] #50 0x185104058 in <redacted>+0x434 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x4ec058)
2021-12-01 15:31:56.049650+0000 ---[1979:545450] #51 0x184e99cdc in UIApplicationMain+0x7e8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x281cdc)
2021-12-01 15:31:56.049949+0000 ---[1979:545450] #52 0x101212988 in main+0x3c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x100426988)
2021-12-01 15:31:56.052728+0000 ---[1979:545450] #53 0x102f6018c (/usr/lib/dyld:arm64+0x1818c)
2021-12-01 15:31:56.053015+0000 ---[1979:545450]
2021-12-01 15:31:56.053260+0000 ---[1979:545450] Address 0x00017b400000 is a wild pointer.
2021-12-01 15:31:56.053516+0000 ---[1979:545450] SUMMARY: AddressSanitizer: bad-free (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438) in wrap_free+0x8c
==1979==ABORTING
【问题讨论】:
-
尝试从代码中的任何位置删除
return。它不应该与完成处理程序一起使用。 -
我已经删除了所有我可以删除的内容(相应地更新了问题) - 无法从
guard语句中删除它们,因为如果我这样做,Xcode 会抱怨。恐怕没有变化! -
这里有同样的问题,但我只有在方案中启用地址清理程序时才会遇到此问题
-
感谢@SyedSaad - 这似乎有效(相应地更新了问题)