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
Related
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.
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.
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)
I'm currently using the Skobbler SDK in an Android app to handle mapping and turn-by-turn direction tasks. One issue that came up was the desire to change to frequency at which audio advice is issued from the SDK so that we don't have too many instructions being fired off one after the other.
I found this answer to another question which explains the need to modify an advice_places.adv file which I was able to find within the SDK provided SKMaps.zip file.
The issue I'm experiencing seems to be related to how I re-archive the zip file once I've finished making changes to the advice_places.adv file. I'm working on a Mac and it seems that regardless of if I use the built-in "Compress..." context menu option or if I perform a zip operation via the command line similar to:
zip -vr SKMaps.zip SKMaps/ -x "*.DS_Store"; chmod +x SKMaps.zip
I still can't seem to load my app without it crashing during the Skobbler SDK map initialization process.
I've narrowed down the issue to it being a zip/unzip related issue since I can recreate the crash even if I don't modify any of the contents of the SKMaps.zip but only unzip and then rezip.
Here is a dump of the logs that I see when my app crashes.
SKMaps D SKMapViewHolder----#onResume
D SKMapSurfaceView----#onResume
D SKMapSurfaceView----#onResume preserve GL context is TRUE
WindowManager V Adding window Window{278f3a43 u0 com.company.mymapapp/com.company.mymapapp.activities.MainActivity} at 23 of 32 (before Window{246caca8 u0 SurfaceView})
V Adding window Window{1b0d49f9 u0 SurfaceView} at 23 of 33 (before Window{278f3a43 u0 com.company.mymapapp/com.company.mymapapp.activities.MainActivity})
SKMaps D MapRenderer----#onSurfaceCreated
D MapRenderer----#onSurfaceCreated LinInitialized = true
D MapRenderer---- #initGLView
SkobblerNG D set density JNI - before NG_SetScreenScale
D set density JNI - after NG_SetScreenScale
libc F Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 24828 (GLThread 44711)
btif_config_util D btif_config_save_file(L188): in file name:/data/misc/bluedroid/bt_config.new
DEBUG I *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I Build fingerprint: 'google/shamu/shamu:5.1/LMY47I/1767468:user/release-keys'
I Revision: '33696'
I ABI: 'arm'
I pid: 24493, tid: 24828, name: GLThread 44711 >>> com.company.mymapapp <<<
I signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
I r0 00000001 r1 00000000 r2 00000001 r3 00000029
I r4 a0edfcd0 r5 00000000 r6 a0edfc00 r7 a044a9b0
I r8 00000000 r9 a044a9d8 sl 00000001 fp 13250820
I ip 80000000 sp a044a978 lr 9e8d5efd pc 9e8d5f22 cpsr 600f0030
I backtrace:
I #00 pc 0018ef22 /data/app/com.company.mymapapp-1/lib/arm/libngnative.so (EarthSphere::SetupTextureInBufferFromTex(SK_WTEXTURE_ID&)+113)
I #01 pc 0018ff23 /data/app/com.company.mymapapp-1/lib/arm/libngnative.so (EarthSphere::Init(unsigned int, unsigned int)+190)
I #02 pc 0011dc7d /data/app/com.company.mymapapp-1/lib/arm/libngnative.so (MapRenderer::InitializeGlobeAndWorldTextures()+116)
I #03 pc 000fe1bd /data/app/com.company.mymapapp-1/lib/arm/libngnative.so (NG_InitializeGL+52)
I #04 pc 000e7fcf /data/app/com.company.mymapapp-1/lib/arm/libngnative.so (Java_com_skobbler_ngx_map_MapRenderer_initgl+14)
I #05 pc 0064b963 /data/dalvik-cache/arm/data#app#com.company.mymapapp-1#base.apk#classes.dex
I Tombstone written to: /data/tombstones/tombstone_07
ActivityManager W Force finishing activity 1 com.company.mymapapp/.activities.MainActivity
BootReceiver I Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE)
JavaBinder E !!! FAILED BINDER TRANSACTION !!!
WindowState I WIN DEATH: Window{23adbb9a u0 SurfaceView}
NetlinkEvent E NetlinkEvent::FindParam(): Parameter 'INTERFACE' not found
E NetlinkEvent::FindParam(): Parameter 'TIME_NS' not found
NetdConnector E Error handling '613 IfaceClass active (null)': java.lang.NumberFormatException: Invalid int: "(null)"
WindowState I WIN DEATH: Window{246caca8 u0 SurfaceView}
I WIN DEATH: Window{259e40bc u0 com.company.mymapapp/com.company.mymapapp.activities.IntroActivity}
I WIN DEATH: Window{278f3a43 u0 com.company.mymapapp/com.company.mymapapp.activities.MainActivity}
I WIN DEATH: Window{1b0d49f9 u0 SurfaceView}
Zygote I Process 24493 exited due to signal (11)
ActivityManager W Exception thrown during pause
W android.os.TransactionTooLargeException
W at android.os.BinderProxy.transactNative(Native Method)
W at android.os.BinderProxy.transact(Binder.java:496)
W at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:704)
W at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:825)
W at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2726)
W at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2583)
W at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2497)
W at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11500)
W at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11397)
W at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12081)
W at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:11592)
W at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
lowmemorykiller E Error opening /proc/24493/oom_score_adj; errno=2
Process com.company.mymapapp (PID: 24493) ended
If anyone has any information as to the preferred method of generating a zip file on a Mac for use with the Skobbler SDK in this fashion, I would appreciate any guidance.
Thank you!
Keith
I've had the same issue (I did the zipping/unzipping manually) - I did not get to the bottom of the problem but the trick is not to zip the SkMaps folder (that you get when unzipping) but the content of that folder (all the subfolders) in an archive named SkMaps.zip (go in the unpacked folder, SKMaps, select all the folder and compress them to an SKMaps.zip.
I'm not sure if this is Mac specific or zip specific. The SDK expects that when unzipping SKMaps.zip it will find a number of folders, but when you compress the SKMaps folder directly you end up with an archive that has as root folder a folder named SkMaps (which is wrong) and only inside that folder the correct folder structure.
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.