KindleHe opened a new issue #4884: [android_deploy] crash is caused by 
`Module.load` func while running App on Android Device with 
URL: https://github.com/apache/incubator-tvm/issues/4884
 
 
   I install the apk in vivo X6S A, according to the [Android TVM 
Demo](https://github.com/apache/incubator-tvm/tree/master/apps/android_deploy)
   
   vivo X6S A is arm64-v8a with android-22, so I modify config.mk as following:
   ```
   APP_ABI = arm64-v8a
   
   APP_PLATFORM = android-22
   
   # whether enable OpenCL during compile
   USE_OPENCL = 0
   
   # the additional include headers you want to add, e.g., 
SDK_PATH/adrenosdk/Development/Inc
   ADD_C_INCLUDES =
   
   # the additional link libs you want to add, e.g., 
ANDROID_LIB_PATH/libOpenCL.so
   ADD_LDLIBS =
   ```
   
   However, I run app in device, the app crash immediately, so I add some lines 
for debug:
   ```
   Log.i(TAG, "libCacheFilePath=" + libCacheFilePath);
   Module modelLib = Module.load(libCacheFilePath);
   Log.i(TAG, "Finish Module.load");
   ```
   
   Then, I use `adb logcat -b main -v time>app.log` command to capture crash on 
android device machine to get the following log file
   [app.log](https://github.com/apache/incubator-tvm/files/4205184/app.log)
   Here is some important information of app.log
   ```
   02-14 23:38:51.469 I/MainActivity(28024): 
libCacheFilePath=/data/data/org.apache.tvm.android.demo/cache/tvm4j_demo_-856121318/deploy_lib_cpu.so
   02-14 23:38:51.469 W/System.err(28024): Try loading tvm4j from native path.
   02-14 23:38:51.469 W/System.err(28024): Try loading tvm4j-linux-x86_64 from 
native path.
   02-14 23:38:51.469 W/System.err(28024): [WARN] TVM native library not found 
in path. Copying native library from the archive. Consider installing the 
library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH), 
or specifying by Java cmd option -Djava.library.path=[lib path].
   02-14 23:38:51.469 W/System.err(28024): Attempting to load libtvm4j.so
   02-14 23:38:51.469 W/System.err(28024): [WARN] Couldn't find native library 
tvm4j.
   02-14 23:38:51.469 W/System.err(28024): java.lang.UnsatisfiedLinkError: 
Couldn't find the resource libtvm4j.so
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.NativeLibraryLoader.extractResourceFileToTempDir(NativeLibraryLoader.java:127)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:87)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.Base.<clinit>(Base.java:73)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.Function.listGlobalFuncNames(Function.java:52)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.Function.getFunction(Function.java:38)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.Module.getApi(Module.java:41)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.Module.load(Module.java:140)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.Module.load(Module.java:146)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:186)
   02-14 23:38:51.469 W/System.err(28024):         at 
org.apache.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:124)
   02-14 23:38:51.469 W/System.err(28024):         at 
android.os.AsyncTask$2.call(AsyncTask.java:292)
   02-14 23:38:51.469 W/System.err(28024):         at 
java.util.concurrent.FutureTask.run(FutureTask.java:237)
   02-14 23:38:51.469 W/System.err(28024):         at 
android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
   02-14 23:38:51.469 W/System.err(28024):         at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   02-14 23:38:51.469 W/System.err(28024):         at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   02-14 23:38:51.469 W/System.err(28024):         at 
java.lang.Thread.run(Thread.java:818)
   02-14 23:38:51.469 W/System.err(28024): Try to load tvm4j (runtime packed 
version) ...
   02-14 23:38:51.469 W/linker  (28024): 
/data/app/org.apache.tvm.android.demo-1/lib/arm64/libtvm4j_runtime_packed.so: 
unused DT entry: type 0x6ffffef5 arg 0x54f0
   02-14 23:38:51.469 W/linker  (28024): 
/data/app/org.apache.tvm.android.demo-1/lib/arm64/libtvm4j_runtime_packed.so: 
unused DT entry: type 0x6ffffffe arg 0x514d8
   02-14 23:38:51.469 W/linker  (28024): 
/data/app/org.apache.tvm.android.demo-1/lib/arm64/libtvm4j_runtime_packed.so: 
unused DT entry: type 0x6fffffff arg 0x2
   02-14 23:38:51.479 W/System.err(28024): libtvm4j loads successfully.
   02-14 23:38:51.479 E/AndroidRuntime(28024): FATAL EXCEPTION: AsyncTask #1
   02-14 23:38:51.479 E/AndroidRuntime(28024): Process: 
org.apache.tvm.android.demo, PID: 28024
   02-14 23:38:51.479 E/AndroidRuntime(28024): java.lang.RuntimeException: An 
error occured while executing doInBackground()
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
android.os.AsyncTask$3.done(AsyncTask.java:304)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.util.concurrent.FutureTask.setException(FutureTask.java:222)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.util.concurrent.FutureTask.run(FutureTask.java:242)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.lang.Thread.run(Thread.java:818)
   02-14 23:38:51.479 E/AndroidRuntime(28024): Caused by: 
java.lang.NullPointerException: Attempt to invoke virtual method 
'org.apache.tvm.Function org.apache.tvm.Function.pushArg(java.lang.String)' on 
a null object reference
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
org.apache.tvm.Module.load(Module.java:140)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
org.apache.tvm.Module.load(Module.java:146)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
org.apache.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:186)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
org.apache.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:124)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
android.os.AsyncTask$2.call(AsyncTask.java:292)
   02-14 23:38:51.479 E/AndroidRuntime(28024):     at 
java.util.concurrent.FutureTask.run(FutureTask.java:237)
   ```
   As you can see,  `libCacheFilePath` occurs while `Finish Module.load` not, 
which means that `Module modelLib = Module.load(libCacheFilePath);` failed. 
Meanwhile, the app.log says `Caused by: java.lang.NullPointerException`. 
   
   So, I locate the crash is caused by `Module.load` func or 
`libCacheFilePath`, however 
`libCacheFilePath=/data/data/org.apache.tvm.android.demo/cache/tvm4j_demo_-856121318/deploy_lib_cpu.so`,
 and I find `deploy_lib_cpu.so` indeed exist in
   ```
   ➜  app git:(dev/kindlehe/walk-through) ✗ find ./ -name deploy_lib_cpu.so
   .//build/intermediates/merged_assets/release/out/deploy_lib_cpu.so
   .//build/intermediates/merged_assets/debug/out/deploy_lib_cpu.so
   .//build/intermediates/assets/release/deploy_lib_cpu.so
   .//build/intermediates/assets/debug/deploy_lib_cpu.so
   .//src/main/assets/deploy_lib_cpu.so
   ```
   Finally, I conclude the crash is caused by `Module.load` func.
   
   But, I don' t know how to sovle the crash problem, begging for your 
kind-hearted help sincerely!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to