Cocos2d-x Android NDK debug Error (9): Bad file descriptor? - android

There is a crash when I am developing an Android application using Cocos2d-x. So I am using ndk-stack and I get this error:
D:\Android\android-ndk-r8e>adb logcat | ndk-stack.exe -sym e:\graduation_project
\cocos2d-x-2.1.5\projects\Test_py\proj.android\obj\local\armeabi\
********** Crash dump: **********
Build fingerprint: 'google/mysid/toro:4.2.2/JDQ39/573038:user/release-keys'
pid: 9911, tid: 9950, name: Thread-1096 >>> com.einverne.test_py <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr ff7a8390
Stack frame #00 pc 0001055e /system/lib/libc.so (dlmalloc+1729): Unable to ope
n symbol file e:\graduation_project\cocos2d-x-2.1.5\projects\Test_py\proj.androi
d\obj\local\armeabi\/libc.so. Error (9): Bad file descriptor
Stack frame #01 pc 0000dcc7 /system/lib/libc.so (malloc+10): Unable to open sy
mbol file e:\graduation_project\cocos2d-x-2.1.5\projects\Test_py\proj.android\ob
j\local\armeabi\/libc.so. Error (9): Bad file descriptor
Stack frame #02 pc 002a4bff /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::unzOpenCurrentFile3(void*, int*, int*, int, char const*)+482): Rou
tine unzOpenCurrentFile3 in e:\graduation_project\cocos2d-x-2.1.5/cocos2dx/suppo
rt/zip_support/unzip.cpp:1494
Stack frame #03 pc 002a4d9f /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::unzOpenCurrentFile(void*)+10): Routine unzOpenCurrentFile in e:\gr
aduation_project\cocos2d-x-2.1.5/cocos2dx/support/zip_support/unzip.cpp:1677
Stack frame #04 pc 002a302d /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::ZipFile::getFileData(std::string const&, unsigned long*)+76): Rout
ine getFileData in e:\graduation_project\cocos2d-x-2.1.5/cocos2dx/support/zip_su
pport/ZipUtils.cpp:556
Stack frame #05 pc 002943c5 /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::CCFileUtilsAndroid::getFileData(char const*, char const*, unsigned
long*)+76): Routine getFileData in e:\graduation_project\cocos2d-x-2.1.5/cocos2
dx/platform/android/CCFileUtilsAndroid.cpp:126
Stack frame #06 pc 00173267 /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (CLuaScriptReader::RunScriptFile(char const*, char*, char*)+46): Routine Run
ScriptFile in jni/../../Classes/LuaScriptReader.cpp:318
Stack frame #07 pc 00172129 /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (JudgeManager::getResult(std::string, std::string, CharacterEntity*, std::st
ring)+200): Routine getResult in jni/../../Classes/JudgeManager.cpp:51
When I come back to my code.
bool CLuaScriptReader::RunScriptFile(const char *filename,char* ret_string,char *name){
if( m_plua == NULL || ret_string == NULL || filename == NULL ) return false;
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
char filebuff[MAX_LUA_FILE_LEN] = "";
char line[1024] = "";
FILE* fpFile = fopen(filename,"r");
if( fpFile == NULL ) {
printf("can not find file %s\n",filename);
return false;
}
while( fgets(line, 1024, fpFile) != NULL) {
strcat(filebuff,line);
}
fclose(fpFile);
RunScriptBuffer(filebuff,ret_string,name);
#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
unsigned long int size = 0;
unsigned char* filebuff = CCFileUtils::sharedFileUtils()->getFileData(filename,"r",&size);
CCString* ccStr = CCString::createWithData(filebuff,size);
RunScriptBuffer(ccStr->getCString(),ret_string,name);
#endif
return true;
}
Error happened in this line:
unsigned char* filebuff = CCFileUtils::sharedFileUtils()->getFileData(filename,"r",&size);
However, I am always using this code to read file under Android. Class CLuaScriptReader can be found here

How do you compile the files?
It seems a problem with the script. The lines:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr ff7a8390
Stack frame #00 pc 0001055e /system/lib/libc.so (dlmalloc+1729): Unable to ope
n symbol file e:\graduation_project\cocos2d-x-2.1.5\projects\Test_py\proj.androi
d\obj\local\armeabi\/libc.so. Error (9): Bad file descriptor
Signal 11 --> A memory fail, and the path go to nowhere. / are for paths in UNIX system, and \ to WINDOWS system, so something is wrong to find libc.so
A Bad file descriptor is a linux, if you get this error message while trying to access a file, the most prominent causes are file system corruption or damaged disk block(s). In such situations, you also get write errors.

Related

ConentResolver ANR's after upgrading libraries and targetSDKVersion 32

I am getting a lot of ANR's in ContentResolver in Firebase Crashlytics since updating all external google libraries and targetSDKVersion 32.
Are there any changes for ContentResolver I have missed in newer libraries/Android version?
For example, I get an ANR if I call my ContentResolver to get only a count:
at com.xxxx.xxx.db.xxxDatabase.getxxxsCount(xxxDatabase.java:1470)
main (native): tid=1 systid=14120
#00 pc 0x4f55c libc.so (syscall + 28)
#01 pc 0x47cc80 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 140)
#02 pc 0x75b88c libart.so (artJniMethodEnd + 204)
#03 pc 0x20facc libart.so (art_jni_method_end + 12)
at android.os.BinderProxy.transactNative(BinderProxy.java)
at android.os.BinderProxy.transact(BinderProxy.java:584)
at android.content.IContentService$Stub$Proxy.unregisterContentObserver(IContentService.java:1005)
at android.content.ContentResolver.unregisterContentObserver(ContentResolver.java:2730)
at android.database.AbstractCursor.onDeactivateOrClose(AbstractCursor.java:157)
at android.database.AbstractWindowedCursor.onDeactivateOrClose(AbstractWindowedCursor.java:213)
at android.database.AbstractCursor.close(AbstractCursor.java:186)
at android.database.sqlite.SQLiteCursor.close(SQLiteCursor.java:207)
at android.database.CursorWrapper.close(CursorWrapper.java:54)
at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:3870)
at com.xxxx.xxx.db.xxxDatabase.getxxxsCount(xxxDatabase.java:1470)
at com.xxxx.xxx.db.xxxDatabase.getFiredOffxxxsCount(xxxDatabase.java:1361)
at com.xxxx.xxx.utilities.xxxNotification.shouldGroup(xxxNotification.java:999)
at com.xxxx.xxx.utilities.xxxNotification.getNotification(xxxNotification.java:720)
at com.xxxx.xxx.utilities.xxxNotification.buildNotification(xxxNotification.java:522)
at com.xxxx.xxx.utilities.xxxNotification.buildNotification(xxxNotification.java:451)
at com.xxxx.xxx.utilities.xxxNotification.updateNotificationGroup(xxxNotification.java:1318)
at com.xxxx.xxx.utilities.xxxNotification.cancelNotification(xxxNotification.java:335)
at com.xxxx.xxx.utilities.xxxNotification.snooze(xxxNotification.java:1915)
at com.xxxx.xxx.AlarmList.snoozeAllNewAlarmTime(AlarmList.java:80)
at com.xxxx.xxx.AlarmList.onFinishSnoozeDialog(AlarmList.java:117)
at com.xxxx.xxx.dialogs.SnoozeDialog.onClick(SnoozeDialog.java:279)
at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I have not changed any code, so I am wondering why this is now happening after upgrading. I think I have missed any background changes in AndroidX or Android SDK 32 version for ContentResolver or queries.
I know this is very generic, but currently I don't know where to check for the problem.
I would be grateful for any help or hint.
Update 28.09.2022:
I get also sometimes ANR's where no class is involved of my app.
main (native): tid=1 systid=9452
#00 pc 0xd6a94 libc.so (__ioctl + 4)
#01 pc 0x935c4 libc.so (ioctl + 156)
#02 pc 0x51a7c libbinder.so (android::IPCThreadState::talkWithDriver(bool) + 296)
#03 pc 0x52a68 libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*) + 60)
#04 pc 0x527d8 libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int) + 184)
#05 pc 0x4b01c libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) + 188)
#06 pc 0x12b3e8 libandroid_runtime.so (android_os_BinderProxy_transact(_JNIEnv*, _jobject*, int, _jobject*, _jobject*, int) + 152)
at android.os.BinderProxy.transactNative(BinderProxy.java)
at android.os.BinderProxy.transact(BinderProxy.java:540)
at bn.h(bn.java:11)
at bk.a(bk.java:3)
at bm.c(bm.java)
at be.d(be.java:2)
at bh.handleMessage(bh.java:28)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8056)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Seems the problems were about the upgrade from the Billing Library 3.x to 5.x!
After reverting to 3.x the ANR's are gone.
Now I have readded the Billing Library from scratch with version 5.x!
No more ANR's or strange behaviors anymore.
Strange, but I think there was a mistake on upgrading to 5.x and this caused some leaks.

calculate runtime offset from runtime address minus readelf function address?

I'm trying to analyse a crash in my android app which calls a function in a shared object outlined as android java->jni->ndk->shared object. I went through the page:
https://source.android.com/devices/tech/debug/native-crash
However, I don't get such nice dumps as in the examples. I only have a stack trace and some lines in the logcat:
stack:
art_sigsegv_fault 0x0000006f2a44b58c
art::FaultManager::HandleFault(int, siginfo*, void*) 0x0000006f2a44b3f8
art::SignalChain::Handler(int, siginfo*, void*) 0x00000071c40cc328
<unknown> 0x00000071ec845668
__cxxabiv1::set_registers(_Unwind_Exception*, _Unwind_Context*, __cxxabiv1::(anonymous namespace)::scan_results const&) 0x0000006e893c8c90
::__gxx_personality_v0(int, _Unwind_Action, uint64_t, _Unwind_Exception *, _Unwind_Context *) 0x0000006e893c8c78
__cxxabiv1::set_registers(_Unwind_Exception*, _Unwind_Context*, __cxxabiv1::(anonymous namespace)::scan_results const&) 0x0000006e893c8c90
::__gxx_personality_v0(int, _Unwind_Action, uint64_t, _Unwind_Exception *, _Unwind_Context *) 0x0000006e893c8c78
unwind_phase2 0x0000006e8c8f8d40
_Unwind_Resume 0x0000006e8c8f8e10
interpreter::combine_nodes(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, node_info const&, node_info const&) 0x0000006e8c8737c0
yy::parser::parse() 0x0000006e8c81dc98
hi(char const*, char const*, unsigned char, char const*, char const*, _JavaVM*, _jobject*, char const*, unsigned char) 0x0000006e8c822988
::Java_com_bitroller_hi_MainActivity_jhi(JNIEnv *, jclass, jstring, jstring, jstring, int, int) jhi.cpp:20
art_quick_generic_jni_trampoline 0x0000006f2a2d4048
<unknown> 0x0000006f2a2d4390
logcat:
2022-08-03 10:46:56.600 2770-2770/com.bitroller.hi A/libc: Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x6e8c909e60 in tid 2770 (om.bitroller.hi), pid 2770 (om.bitroller.hi)
2022-08-03 10:46:56.647 3108-3108/? A/libc: failed to exec crash_dump helper: Operation not permitted
2022-08-03 10:46:56.648 927-927/? E/audit: type=1400 audit(1659516416.643:128328): avc: denied { ptrace } for pid=3108 comm="om.bitroller.hi" scontext=u:r:runas_app:s0:c57,c257,c512,c768 tcontext=u:r:crash_dump:s0:c57,c257,c512,c768 tclass=process permissive=0 SEPF_SM-A725F_12_0001 audit_filtered
2022-08-03 10:46:56.664 2770-2770/com.bitroller.hi A/libc: crash_dump helper failed to exec, or was killed
2022-08-03 10:46:56.665 2770-2770/com.bitroller.hi A/libc: failed to wait for crash_dump helper: No child processes
So I thought about:
taking the address of the function I know i.e. interpreter::combine_nodes() from the stack trace
checking the address of that function by readelf in the shared library
subtracting the address in 2) from the address in 1) i.e 1)addr - 2)addr
subtracting the address I get in 3) from the failure address in the stack trace i.e. 0x0000006f2a44b58c - 3)addr
check the address I get in 4) by addr2line and identify the line in the source of the shared library where the program failed
Does this make sense? Currently, I just tested what I get if I use addr2line on an address of the function mentioned read by readelf but it returns ??:0. Does anyone have any hint what am I doing wrong?
It turns out after two months of investigation (one before reporting this and one after that) that this unwinding problem only occurs if the native code is cross-compiled by a standalone toolchain. I had the chance to import the cpp source code of the library that crashes in android studio, compile it there and there's no more crash during unwind.

SIGABRT when exception is thrown from .so in Android when 3rd party lib is used statically

I have a native Android, SDK style library which depends on OpenCV.
In order to avoid conflict when a user uses the library and their own usage with OpenCV, I want to compile OpenCV statically into my library and hide its symbols.
I compiled OpenCV (3.4.13 world module) statically and used it, along with its 3rd party libraries in my library.
When I try and use my library, and it throws an exception, even if the exception is caught by the user, a SIGABRT is causing the app to terminate.
This is the stack trace from the logcat
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24115 (.test), pid 24115 (.test)
...
A/DEBUG: backtrace:
A/DEBUG: #00 pc 0000000000051948 /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 931371c1098ffd5adc489b9ff4da8e82)
A/DEBUG: #01 pc 00000000000b2ba0 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
A/DEBUG: #02 pc 00000000000aec8c /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libc++_shared.so (__gxx_personality_v0+348) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
A/DEBUG: #03 pc 00000000004dd2dc /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #04 pc 00000000004dd7e4 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #05 pc 0000000000170600 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (mylib::TestClass::TestClass(char const*, char const*)+908) (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #06 pc 000000000000c5d0 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #07 pc 000000000000c3b8 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #08 pc 000000000000c308 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (Java_com_example_lib_Engine_cxxInit+56) (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #09 pc 00000000002d7644 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 2b417e2566f5eb686666666b6ee952ea)
(It also happens if the JNI library uses c++_static, but in that case the __gxx_personality_v0 and 1 above it come from the libJnilibrary.so)
If I compile OpenCV as a shared library and link my library against it, then everything works fine.
I've had issues with exceptions in my library before, see this question I asked. I solved it by compiling everything using c++_static STL. The problem looks similar to this, and indeed I was missing the key function, but even after adding it, the problem keeps happening.
I looked at the symbols using llvm-readelf -CWs and noticed that when OpenCV is linked dynamically, in addition to OpenCV symbols, the output contains some ndk and cxxabi symbols which doesn't exist when OpenCV is used statically. I don't know if it's related at all but for example
110: 0000000000000000 0 FUNC GLOBAL DEFAULT UND std::uncaught_exception()
...
201: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND vtable for __cxxabiv1::__vmi_class_type_info
...
231: 0000000000000000 0 FUNC GLOBAL DEFAULT UND std::__ndk1::to_string(unsigned int)
(All of these are missing when using statically built OpenCV)
I'm using ndk version 21e (I can't use higher version at the moment because another library uses Bazel and it only supports up to 21 at the moment)
OpenCV is built with the following flags
cmake -DCMAKE_BUILD_TYPE=Release -DINSTALL_ANDROID_EXAMPLES=OFF -DANDROID_EXAMPLES_WITH_LIBS=OFF -DANDROID_ABI="arm64-v8a"
-DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DANDROID_ARM_NEON=1
-DANDROID_STL=c++_static -DANDROID_PLATFORM=android-21 -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake"
-DBUILD_SHARED_LIBS=OFF -DBUILD_FAT_JAVA_LIB=OFF -DBUILD_JAVA=OFF -DINSTALL_CREATE_DISTRIB=ON -DINSTALL_ANDROID_EXAMPLES=OFF -DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_video=ON -DBUILD_opencv_videoio=ON -DBUILD_opencv_features2d=ON -DBUILD_opencv_flann=OFF -DBUILD_opencv_highgui=ON -DBUILD_opencv_ml=OFF
-DBUILD_opencv_photo=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_shape=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_superres=OFF -DBUILD_opencv_ts=OFF
-DBUILD_opencv_videostab=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_opencv_world=ON -DBUILD_opencv_dnn=OFF -DBUILD_opencv_core=ON -DBUILD_opencv_imgcodecs=ON
-DBUILD_opencv_imgproc=ON -DBUILD_opencv_calib3d=ON -GNinja -DCMAKE_INSTALL_PREFIX=../install -DBUILD_ZLIB=1 -DWITH_PROTOBUF=OFF -DWITH_QUIRC=OFF ..
My libray is compiled using Gradle and Android Studio with these CMake flags
externalNativeBuild {
cmake {
cppFlags "-std=c++17 -static-openmp -fopenmp -fexceptions -frtti -Wno-unused-command-line-argument -Wl,-s"
cppFlags "-Wl,--exclude-libs,libc++_static.a -Wl,--exclude-libs,libc++abi.a"
arguments "-DANDROID_STL=c++_static", "-DANDROID_ARM_NEON=TRUE"
}
}
The issue wasn't related to the 3rd party or anything like this at all eventually.
I was using NDK version r21e. Upgrading the NDK to r24 fixed the issue.
It seems that when linking OpenCV as a shared object, it masked the actual NDK bug by importing or including some of the missing/problematic symbols and when we stopped using it, the error appeared.

Unusual segmentation fault coming randomly cocos2dx android

I am using cocos2dx v3.9 with ndk 10e with android 4.4.2 .I have created a layer and on that button is present . When button is pressed layer is removed from parent and clean up is performed and other task is performed. Crash is coming when button is pressed, mostly when tapped as soon as button appears.
code on button click is:-
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("tap.wav");
unschedule(schedule_selector(InstructionLayer::callNextButtonMethod));
if (this->delegate != NULL) {
delegate->clickNextButton();
} else {
CCLOG("Delegate null");
}
this->removeFromParentAndCleanup(true);
}
and my ndk crash dump is :-
********** Crash dump: **********
Build fingerprint: 'iNet/astar_ibt_8723bs/astar-ibt-8723bs:4.4.2/KVT49L/20140925:eng/test-keys'
pid: 14096, tid: 14115, name: Thread-1145 >>> com.Sample.Test <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 6d12a000
Stack frame #00 pc 00022090 /system/lib/libc.so (__memcpy_base+176)
Stack frame #01 pc 00a57f29 /data/app-lib/com.Sample.Test-2/libcocos2dcpp.so: Routine unaligned_load at /s/ndk-toolchain/src/gcc/gcc-4.9/libstdc++-v3/libsupc++/hash_bytes.cc:43
Stack frame #02 pc 00424da8 /data/app-lib/com.Sample.Test-2/libcocos2dcpp.so (std::_Hash_impl::hash(void const*, unsigned int, unsigned int)+36): Routine std::_Hash_impl::hash(void const*, unsigned int, unsigned int) at /ShobhitPC/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/functional_hash.h:131
Stack frame #03 pc 00424df8 /data/app-lib/com.Sample.Test-2/libcocos2dcpp.so (std::hash<std::string>::operator()(std::string const&) const+56): Routine std::hash<std::string>::operator()(std::string const&) const at /ShobhitPC/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:3084 (discriminator 2)

Proper way to finish Tesseract API

I'm implementing OCR app which uses Tesseract API. When I press Android home button, popup window "Unfortunately has stopped" appears. I'm running TessbaseAPI multiple times in OCR thread with handler defined. I send messages with image for OCR purposes and thread process it.
After every image I call Tessbase's clear() and at Activity's onPause() method end(). There is probably problem in calling end() while image is processed. Does anyone have advice how to solve this? Thanks in advance.
Logcat error:
03-13 13:18:56.882: A/libc(24730): Fatal signal 11 (SIGSEGV) at 0x00000010 (code=1), thread 24756 (Thread-6411)
ndk-stack output:
********** Crash dump: **********
Build fingerprint: 'google/yakju/maguro:4.3/JWR66Y/776638:user/release-keys'
pid: 24730, tid: 24756, name: Thread-6411 >>> cz.skywall.dp <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000010
Stack frame #00 pc 000cb132 /data/app-lib/cz.skywall.dp-1/libtess.so (ExtractIntFeat(TBLOB*, DENORM const&, INT_FEATURE_STRUCT*, INT_FEATURE_STRUCT*, INT_FX_RESULT_STRUCT*, int*)+49): Unable to open symbol file /home/lukas/Stažené/tess-two- master/tess-two/libs/armeabi/libtess.so. Error (9): Bad file descriptor
Stack frame #01 pc 000c1715 /data/app-lib/cz.skywall.dp-1/libtess.so (tesseract::Classify::GetCharNormFeatures(TBLOB*, DENORM const&, INT_TEMPLATES_STRUCT*, INT_FEATURE_STRUCT*, unsigned char*, unsigned char*, int*, int*)+56): Unable to open symbol file /home/lukas/Stažené/tess-two-master/tess-two/libs/armeabi/libtess.so. Error (9): Bad file descriptor
Stack frame #02 pc 000c1e3d /data/app-lib/cz.skywall.dp-1/libtess.so (tesseract::Classify::CharNormClassifier(TBLOB*, DENORM const&, INT_TEMPLATES_STRUCT*, ADAPT_RESULTS*)+84): Unable to open symbol file /home/lukas/Stažené/tess-two-master/tess-two/libs/armeabi/libtess.so. Error (9): Bad file descriptor
Stack frame #03 pc 000c27a1 /data/app-lib/cz.skywall.dp-1/libtess.so (tesseract::Classify::DoAdaptiveMatch(TBLOB*, DENORM const&, ADAPT_RESULTS*)+100): Unable to open symbol file /home/lukas/Stažené/tess-two-master/tess-two/libs/armeabi/libtess.so. Error (9): Bad file descriptor
Stack frame #04 pc 000c285b /data/app-lib/cz.skywall.dp-1/libtess.so (tesseract::Classify::AdaptiveClassifier(TBLOB*, DENORM const&, BLOB_CHOICE_LIST*, CP_RESULT_STRUCT*)+90): Unable to open symbol file /home/lukas/Stažené/tess-two-master/tess-two/libs/armeabi/libtess.so. Error (9): Bad file descriptor

Categories

Resources