cocos2dx android 9,Cocos2d-x Android NDK調試錯誤(9):錯誤的文件描述符?

在使用Cocos2d-x开发Android应用时遇到崩溃问题,通过ndk-stack分析得到错误信息,涉及内存分配错误和libc.so文件问题。错误发生在尝试读取文件时,代码中使用了`CCFileUtils::sharedFileUtils()->getFileData`方法。可能原因是文件路径错误或内存管理问题。
摘要由CSDN通过智能技术生成

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:

在使用Cocos2d-x開發Android應用程序時,會出現崩潰。我在使用ndk-stack,我得到了這個錯誤:

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

但是,我一直在使用這段代碼來讀取Android下的文件。可以在這里找到類cluattribuptreader

1 个解决方案

#1

0

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

信號11——>內存失敗,路徑將無目的地。/表示UNIX系統中的路徑,以及到WINDOWS系統的路徑,因此找到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.

一個壞的文件描述符是linux,如果您在試圖訪問一個文件時收到這個錯誤消息,最主要的原因是文件系統損壞或磁盤塊損壞。在這種情況下,還會出現寫錯誤。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值