omicronapps / 7-Zip-JBinding-4Android

Android Java wrapper for 7z archiver engine
GNU Lesser General Public License v2.1
121 stars 24 forks source link

compress crash: JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0xb49f9fcc #1

Closed vfishv closed 5 years ago

vfishv commented 5 years ago

2019-11-20 14:02:12.754 5527-6040/com.folderv.file A/om.folderv.fil: java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0xb49f9fcc 2019-11-20 14:02:12.760 5527-6038/com.folderv.file E/7ZipJCompressOpt: complete:3343459 2019-11-20 14:02:12.934 5527-6038/com.folderv.file E/7ZipJCompressOpt: complete:3376228 2019-11-20 14:02:12.941 5527-6038/com.folderv.file E/7ZipJCompressOpt: complete:3408996 2019-11-20 14:02:12.949 5527-6038/com.folderv.file E/7ZipJCompressOpt: complete:3441764 2019-11-20 14:02:12.957 5527-6038/com.folderv.file E/7ZipJCompressOpt: complete:3474532 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] Runtime aborting... 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] Dumping all threads without mutator lock held 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] All threads: 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] DALVIK THREADS (72): 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] "Thread-40" prio=5 tid=45 Runnable 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] | group="" sCount=0 dsCount=0 flags=0 obj=0x12d40000 self=0xd57db000 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] | sysTid=6040 nice=0 cgrp=default sched=0/0 handle=0xb4624230 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] | state=R schedstat=( 292354899 19213329 506 ) utm=28 stm=0 core=4 HZ=100 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] | stack=0xb4529000-0xb452b000 stackSize=1008KB 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] | held mutexes= "abort lock" "mutator lock"(shared held) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #00 pc 002fdea7 /apex/com.android.runtime/lib/libart.so (art::DumpNativeStack(std::1::basic_ostream<char, std::__1::char_traits>&, int, BacktraceMap, char const, art::ArtMethod, void, bool)+78) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #01 pc 003a676b /apex/com.android.runtime/lib/libart.so (art::Thread::DumpStack(std::1::basic_ostream<char, std::1::char_traits>&, bool, BacktraceMap*, bool) const+358) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #02 pc 003a2f43 /apex/com.android.runtime/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::1::char_traits>&, bool, BacktraceMap, bool) const+34) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #03 pc 003bb7bd /apex/com.android.runtime/lib/libart.so (art::DumpCheckpoint::Run(art::Thread)+576) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #04 pc 003b616d /apex/com.android.runtime/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure, art::Closure)+296) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #05 pc 003b588d /apex/com.android.runtime/lib/libart.so (art::ThreadList::Dump(std::1::basic_ostream<char, std::1::char_traits>&, bool)+1416) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #06 pc 00375ddf /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char const)+1058) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #07 pc 0000855f /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+406) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #08 pc 00287a4f /apex/com.android.runtime/lib/libart.so (art::JavaVMExt::JniAbort(char const, char const)+1194) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #09 pc 00287bf1 /apex/com.android.runtime/lib/libart.so (art::JavaVMExt::JniAbortF(char const, char const, ...)+64) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #10 pc 003ab14f /apex/com.android.runtime/lib/libart.so (art::Thread::DecodeJObject(_jobject) const+538) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #11 pc 0027cbd5 /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckInstance(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck::InstanceKind, _jobject, bool)+80) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #12 pc 0027c0fd /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+424) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #13 pc 0027b947 /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const, art::(anonymous namespace)::JniValueType)+634) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #14 pc 002810b3 /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetField(char const, _JNIEnv, _jobject, _jfieldID, bool, art::Primitive::Type)+538) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #15 pc 00271727 /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetBooleanField(_JNIEnv, _jobject, _jfieldID)+38) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #16 pc 00088385 /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (isUserTraceEnabled(JNIEnvInstance&, _jobject*)+8) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #17 pc 000945f7 /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (CPPToJavaArchiveUpdateCallback::GetStream(unsigned int, ISequentialInStream*)+82) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #18 pc 000bb157 /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (NArchive::N7z::CFolderInStream::OpenStream()+86) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #19 pc 000bb395 /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (NArchive::N7z::CFolderInStream::Read(void, unsigned int, unsigned int)+64) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #20 pc 000c6cc5 /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (CSequentialInStreamSizeCount2::Read(void, unsigned int, unsigned int*)+32) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #21 pc 000a0853 /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (???) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #22 pc 0013289d /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (???) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #23 pc 0013448f /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (HashThreadFunc+206) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #24 pc 00134aad /data/app/com.folderv.file-cq1k4c_jYsqyrH_f-xYBBQ==/lib/arm/lib7-Zip-JBinding.so (???) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #25 pc 000a6093 /apex/com.android.runtime/lib/bionic/libc.so (pthread_start(void*)+20) 2019-11-20 14:02:12.964 5527-6040/com.folderv.file A/om.folderv.fil: runtime.cc:630] native: #26 pc 00060763 /apex/com.android.runtime/lib/bionic/libc.so (start_thread+30)

omicronapps commented 5 years ago

It appears that the crash occurs in userTrace() when CPPToJavaArchiveUpdateCallback::GetStream() tries to access Java boolean object OutArchiveImpl.trace.

This Android port uses 7-Zip-JBinding's existing JNI-binding implementation with only minor modifications (loading the native library and handling Unicode-strings), so for JNI object errors it may be that this is caused by differences in how the Android ART Java JVM garbage collects objects.

Further debugging would be required to determine the cause of the invalid JNI object reference.

Do you have a source code sample for reproducing this crash?

vfishv commented 5 years ago

https://github.com/vfishv/AndroidTestProject/tree/master/SimpleFileExplorer

This is a simple test project,long press a folder to compress files in the folder. compress codes in CompressTest.java

vfishv commented 5 years ago

I try to remove calling userTrace() ,it also crash .

omicronapps commented 5 years ago

Initial implementation did not support JNI access from native threads.

This should now be resolved in commit a88f5403814a86e0d2d85937c13ff8b1c058ab9f).

vfishv commented 5 years ago

It works! awesome!