ConentResolver ANR's after upgrading libraries and targetSDKVersion 32 - android

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.

Related

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.

Getting ANR at Violation.kt line 28 caused by FragmentStrictMode

Firebase crashlytics recently started logging one ANR related to FragmentManager.
Below is the concise Stacktrace ->
main (runnable): tid=1 systid=14811
#00 pc 0x483028 libart.so
#01 pc 0x588888 libart.so
#02 pc 0x5a56d4 libart.so
#03 pc 0x589564 libart.so
#04 pc 0x6286ec libart.so
at java.lang.Throwable.nativeFillInStackTrace(Throwable.java)
at java.lang.Throwable.fillInStackTrace(Throwable.java:799)
at java.lang.Throwable.(Throwable.java:277)
at java.lang.Exception.(Exception.java:66)
at java.lang.RuntimeException.(RuntimeException.java:62)
at androidx.fragment.app.strictmode.Violation.(Violation.kt:28)
at androidx.fragment.app.strictmode.SetUserVisibleHintViolation.(SetUserVisibleHintViolation.kt:30)
at androidx.fragment.app.strictmode.FragmentStrictMode.onSetUserVisibleHint(FragmentStrictMode.java:131)
at androidx.fragment.app.Fragment.setUserVisibleHint(Fragment.java:1335)
at androidx.fragment.app.FragmentStatePagerAdapter.instantiateItem(FragmentStatePagerAdapter.java:196)
at com.frran.ui.adapter.HomeMenuPagerAdapter.instantiateItem(HomeMenuPagerAdapter.java:106)
at com.frran.ui.custom.viewpager.PagerAdapterWrapper.instantiateItem(PagerAdapterWrapper.java:56)
at com.frran.ui.custom.viewpager.RtlViewPager$ReverseAdapter.instantiateItem(RtlViewPager.java:192)
at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1224)
at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:669)
at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:631)
at androidx.viewpager.widget.ViewPager.setCurrentItem(ViewPager.java:623)
at com.frran.ui.custom.viewpager.RtlViewPager.setCurrentItem(RtlViewPager.java:74)
Dependencies i am using ->
def fragment_version = "1.4.1"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.appcompat:appcompat:1.3.1"
I am using FragmentStatePagerAdapter with default behavior BEHAVIOR_SET_USER_VISIBLE_HINT i think it has something to do with it but i can not find anything to back this up.
Looking at the fragment version 1.4.0 release notes i found FragmentStrictMode is available to debug the fragment . but it clearly says with the default policy it will not anything if disabled and i did not enabled it manually.
Can i get some help on this Since its a Violation logged by FragmentStrictMode do i have to worry about this ? if not how come crashlytics is logging it even if its disabled in release build.

dlsym: undefined symbol, Android N

I would like to read value from the Android runtime shared library in my application.
Since Android 5, when the new runtime was introduced and libart.so has first appeared, I am doing it successfully with this code:
std::unique_ptr<void, int(*)(void*)> handle {
dlopen("libart.so", RTLD_NOW | RTLD_GLOBAL),
&dlclose
};
constexpr char THREAD_KEY_NAME[] = "_ZN3art6Thread17pthread_key_self_E";
key_ = static_cast<pthread_key_t *>(dlsym(handle.get(), THREAD_KEY_NAME));
LOG("Current thread: ", key_);
I'm testing this code on Android N simulator, and it fails! dlsym returns:
undefined symbol: _ZN3art6Thread17pthread_key_self_E
I think "OK, there is no symbol now", so I pull the libart.so from simulator and see:
% ./i686-linux-android-nm ~/Desktop/libart.so | grep pthread_key
00736ea0 B _ZN3art6Thread17pthread_key_self_E
hmm...
% ./i686-linux-android-objdump -T ~/Desktop/libart.so | grep pthread_key
00736ea0 g DO .bss 00000004 Base .protected _ZN3art6Thread17pthread_key_self_E
hmm..
% ./i686-linux-android-readelf -a ~/Desktop/libart.so | grep pthread_key_self
%
OK, empty there :(
So, while I'm not fully expert in these things, i have some questions:
Why is readelf output is empty? There is some flags i forgot?
What does .protected means in objdump output? I have read some things about it but don't really understand. May be you can get good explanation?
Why dlsym returns error on new versions of Android? What the difference?
BTW, I dumped /proc/self/maps file for my application on both Android versions and grep libart.so gives me:
Android L (which works fine):
b40f3000-b45f3000 r-xp 00000000 1f:00 777 /system/lib/libart.so
b45f3000-b45fb000 r--p 004ff000 1f:00 777 /system/lib/libart.so
b45fb000-b45fc000 rw-p 00507000 1f:00 777 /system/lib/libart.so
Android N (does not work):
aaef1000-aaef2000 r-xp 00000000 fd:00 729 /system/fake-libs/libart.so
aaef2000-aaef3000 r--p 00000000 fd:00 729 /system/fake-libs/libart.so
aaef3000-aaef4000 rw-p 00001000 fd:00 729 /system/fake-libs/libart.so
abc53000-ac373000 r-xp 00000000 fd:00 1034 /system/lib/libart.so
ac374000-ac37c000 r--p 00720000 fd:00 1034 /system/lib/libart.so
ac37c000-ac37e000 rw-p 00728000 fd:00 1034 /system/lib/libart.so
Thanks for any information!
upd: I see there is two libart.so on Android N, and /system/fake-libs/libart.so is empty. I suppose there is a problem, but dlopen("/system/lib/libart.so", ...) does not works :(
In Android N you can not open some private so file(https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk)
But you can open libart.so for Android-N use this:
https://github.com/crmulliner/adbi/blob/master/hijack/hijack.c
or
https://github.com/avs333/Nougat_dlfunctions

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)

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

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.

Categories

Resources