title: Cocos2d-x Android project random crash libc fatal signal 11 error?
body: <p>I am using Cocos2d-x to build both Win32 and Android application. However I met a fatal problem when I try to port to Android from Win32. I wrote following code in Android try to read a file from assets. But, each time Android application crashes at <code>CCFileUtils::sharedFileUtils()-&gt;getFileData</code>. I don't know why. I am using this code in other places, and they all work fine.</p>
  
  <pre><code>#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
      unsigned long size = 0;
      CCLog("filepath name %s",filename);
      unsigned char* filebuff = CCFileUtils::sharedFileUtils()-&gt;getFileData(filename,"rb",&amp;size);
      CCLog("filebuff");
      CCString* ccStr = CCString::createWithData(filebuff,size);
      CCLog("ccstr end");
      RunScriptBuffer(ccStr-&gt;getCString(),ret_string,name);
  #endif
  </code></pre>
  
  <p>This is the whole function implementation:</p>
  
  <pre><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 size = 0;
      CCLog("filepath name %s",filename);
      unsigned char* filebuff = CCFileUtils::sharedFileUtils()-&gt;getFileData(filename,"rb",&amp;size);
      CCLog("filebuff %l",size);
      CCString* ccStr = CCString::createWithData(filebuff,size);
      CCLog("ccstr end");
      RunScriptBuffer(ccStr-&gt;getCString(),ret_string,name);
  #endif
      return true;
  }
  </code></pre>
  
  <p>following is the error log I got using ndk-stack tool.</p>
  
  <pre><code>********** Crash dump: **********
  Build fingerprint: 'google/yakju/maguro:4.3/JWR66Y/776638:user/release-keys'
  pid: 20518, tid: 20541, name: Thread-61225  &gt;&gt;&gt; com.einverne.test_py &lt;&lt;&lt;
  signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr e72d2d24
  Stack frame #00  pc 00010354  /system/lib/libc.so (dlmalloc+1207): Unable to ope
  n symbol file d:\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 d:\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 0000aa98  /system/lib/libz.so (inflateInit2_+100)
  Stack frame #03  pc 00523044  /data/app-lib/com.einverne.test_py-2/libcocos2dcpp
  .so (cocos2d::unzOpenCurrentFile3(void*, int*, int*, int, char const*)+836): Rou
  tine unzOpenCurrentFile3 in D:\graduation_project\cocos2d-x-2.1.5/cocos2dx/suppo
  rt/zip_support/unzip.cpp:1618
  Stack frame #04  pc 00523138  /data/app-lib/com.einverne.test_py-2/libcocos2dcpp
  .so (cocos2d::unzOpenCurrentFile(void*)+40): Routine unzOpenCurrentFile in D:\gr
  aduation_project\cocos2d-x-2.1.5/cocos2dx/support/zip_support/unzip.cpp:1677
  Stack frame #05  pc 0051d318  /data/app-lib/com.einverne.test_py-2/libcocos2dcpp
  .so (cocos2d::ZipFile::getFileData(std::string const&amp;, unsigned long*)+360): Rou
  tine getFileData in D:\graduation_project\cocos2d-x-2.1.5/cocos2dx/support/zip_s
  upport/ZipUtils.cpp:561
  Stack frame #06  pc 004ef98c  /data/app-lib/com.einverne.test_py-2/libcocos2dcpp
  .so (cocos2d::CCFileUtilsAndroid::getFileData(char const*, char const*, unsigned
   long*)+252): Routine getFileData in D:\graduation_project\cocos2d-x-2.1.5/cocos
  2dx/platform/android/CCFileUtilsAndroid.cpp:134
  Stack frame #07  pc 00243ab4  /data/app-lib/com.einverne.test_py-2/libcocos2dcpp
  .so (CLuaScriptReader::RunScriptFile(char const*, char*, char*)+152): Routine Ru
  nScriptFile in jni/../../Classes/LuaScriptReader.cpp:330
  Stack frame #08  pc 0023e704  /data/app-lib/com.einverne.test_py-2/libcocos2dcpp
  .so (JudgeManager::getResult(std::string, std::string, std::string, CharacterExt
  end*, std::string)+1004): Routine getResult in jni/../../Classes/JudgeManager.cp
  p:87
  </code></pre>
  
  <p><strong>Edit</strong>: In Android Logcat I got <code>Fatal signal 11 (SIGSEGV) at 0xe72d2d24 (code=1), thread 26592 (Thread-61675)</code> error.</p>