当在我的应用程序内部按下主页按钮,然后重新进入应用程序时,我经常会在重复几次之后遇到崩溃(应用程序通常会自动重启)。日志提示我在malloc_error_break中设置一个断点来调试我已经完成的过程,问题似乎是在baseapi.h
(一个用于调用tesseract的API)的函数中捕获的:
int Init(const char* datapath, const char* language) {
return Init(datapath, language, OEM_DEFAULT, NULL, 0, NULL, NULL, false);
}
我在读完这里的一些帖子之后理解这与尝试dealloc或释放一些未分配的对象有关。但我不确定从哪里开始。问题是否比我上面显示的功能更进一步?
编辑堆栈跟踪:
malloc: *** error for object 0x1700f4800: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
(lldb) bt
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
malloc: *** error for object 0x1740f1880: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x000000018344b4d0 libsystem_malloc.dylib`malloc_error_break
frame #1: 0x000000018344e98c libsystem_malloc.dylib`nanozone_error + 240
frame #2: 0x000000018344fc54 libsystem_malloc.dylib`_nano_malloc_check_clear + 412
frame #3: 0x000000018344ec38 libsystem_malloc.dylib`nano_malloc + 44
frame #4: 0x000000018343d664 libsystem_malloc.dylib`malloc_zone_malloc + 172
frame #5: 0x000000018344056c libsystem_malloc.dylib`malloc + 32
frame #6: 0x0000000182e5f6b0 libc++abi.dylib`operator new(unsigned long) + 48
frame #7: 0x0000000100187354 `tesseract::BoolParam::BoolParam(bool, char const*, char const*, bool, tesseract::ParamsVectors*) + 180
frame #8: 0x000000010014de38 `tesseract::Classify::Classify() + 756
frame #9: 0x000000010025179c `tesseract::Wordrec::Wordrec() + 40
frame #10: 0x0000000100228068 `tesseract::Tesseract::Tesseract() + 48
frame #11: 0x00000001001afe90 `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool) + 204
frame #12: 0x00000001000a3da8 `tesseract::TessBaseAPI::Init(this=0x00000001700f4780, datapath="/var/mobile/Containers/Data/Application/E1BDEDD1-C610-4394-86B7-B4AAFBA47864/Documents/tessdata", language="eng") at baseapi.h:175
frame #13: 0x00000001000a3c5c `::+[TesseractSingleton setUp](self=TesseractSingleton, _cmd="setUp") at TesseractSingleton.mm:36
frame #14: 0x000000010007b988 `-[AppDelegate applicationWillEnterForeground:](self=0x000000014d902670, _cmd="applicationWillEnterForeground:", application=0x000000014bd02e20) at AppDelegate.m:254
frame #15: 0x000000018a794e14 UIKit`-[UIApplication _sendWillEnterForegroundCallbacks] + 172
frame #16: 0x000000018a7d098c UIKit`-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:] + 2080
frame #17: 0x000000018a7cfef8 UIKit`-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 448
frame #18: 0x000000018a7bb4a8 UIKit`__70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 152
frame #19: 0x000000018a7bb124 UIKit`-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 892
frame #20: 0x000000018aaf57c8 UIKit`-[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464
frame #21: 0x0000000185f8a22c FrontBoardServices`__80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.376 + 208
frame #22: 0x0000000185fb7884 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
frame #23: 0x0000000185fb76f0 FrontBoardServices`-[FBSSerialQueue _performNext] + 176
frame #24: 0x0000000185fb7aa0 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56
frame #25: 0x00000001843bd42c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #26: 0x00000001843bcd9c CoreFoundation`__CFRunLoopDoSources0 + 540
frame #27: 0x00000001843ba9a8 CoreFoundation`__CFRunLoopRun + 744
frame #28: 0x00000001842eada4 CoreFoundation`CFRunLoopRunSpecific + 424
frame #29: 0x0000000185d54074 GraphicsServices`GSEventRunModal + 100
frame #30: 0x000000018a59e058 UIKit`UIApplicationMain + 208
frame #31: 0x00000001000792fc `main(argc=1, argv=0x000000016fd8bac8) at main.m:20
frame #32: 0x00000001832f959c libdyld.dylib`start + 4
(lldb)