Author Topic: StreamFree crash  (Read 397 times)

rdkartono

  • Posts: 33
StreamFree crash
« on: 17 Oct '19 - 05:55 »
On some random times, Bass_StreamFree on Android can make application crash.
It not always happened.

I opened a handle using this code :
Code: [Select]
handle = bassloader.BASS_StreamCreateFile(namafile, 0, 0, initflag);

where initflag is :
initflag = BASS.BASS_SAMPLE_MONO;
I dont use AUTOFREE flag.

Sometimes when I want to close handle, using this code, app can crash :
Code: [Select]
if (handle != 0) {
bassloader.BASS_StreamFree(handle);
handle = 0;
}

Debug Log on crash is :
Code: [Select]

art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: native code passing in reference to invalid global reference: 0x360032
art/runtime/check_jni.cc:65]     in call to DeleteGlobalRef
art/runtime/check_jni.cc:65]     from boolean com.un4seen.bass.BASS.BASS_StreamFree(int)
art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x74c44000 self=0xf83bf810
art/runtime/check_jni.cc:65]   | sysTid=29356 nice=0 cgrp=default sched=0/0 handle=0xf77c5e80
art/runtime/check_jni.cc:65]   | state=R schedstat=( 18841251108 4425847695 28892 ) utm=1693 stm=190 core=0 HZ=100
art/runtime/check_jni.cc:65]   | stack=0xff177000-0xff179000 stackSize=8MB
art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
art/runtime/check_jni.cc:65]   native: #00 pc 00005f8b  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+91)
art/runtime/check_jni.cc:65]   native: #01 pc 00003052  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+34)
art/runtime/check_jni.cc:65]   native: #02 pc 0039cbe8  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+136)
art/runtime/check_jni.cc:65]   native: #03 pc 0036703b  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+267)
art/runtime/check_jni.cc:65]   native: #04 pc 00101d4f  /system/lib/libart.so (art::JniAbort(char const*, char const*)+879)
art/runtime/check_jni.cc:65]   native: #05 pc 001029df  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+111)
art/runtime/check_jni.cc:65]   native: #06 pc 00106c01  /system/lib/libart.so (art::ScopedCheck::Check(bool, char const*, ...) (.constprop.130)+1057)
art/runtime/check_jni.cc:65]   native: #07 pc 0011865b  /system/lib/libart.so (art::CheckJNI::DeleteGlobalRef(_JNIEnv*, _jobject*)+123)
art/runtime/check_jni.cc:65]   native: #08 pc 0000ece7  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/check_jni.cc:65]   native: #09 pc 0000ed17  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/check_jni.cc:65]   native: #10 pc 00026184  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/check_jni.cc:65]   native: #11 pc 00028499  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/check_jni.cc:65]   native: #12 pc 0002af59  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (BASS_StreamFree+92)
art/runtime/check_jni.cc:65]   native: #13 pc 0002af89  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (Java_com_un4seen_bass_BASS_BASS_1StreamFree+27)
art/runtime/check_jni.cc:65]   native: #14 pc 00003896  /data/dalvik-cache/x86/data@app@gtc.armivx3k-2@base.apk@classes.dex (Java_com_un4seen_bass_BASS_BASS_1StreamFree__I+122)
art/runtime/check_jni.cc:65]   native: #15 pc 007f90d7  [stack] (???)
art/runtime/check_jni.cc:65]   at com.un4seen.bass.BASS.BASS_StreamFree(Native method)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
art/runtime/check_jni.cc:65]   at audiobass.bassloader.BASS_StreamFree(bassloader.java:2194)
art/runtime/check_jni.cc:65]   at supporting.FileInformation.CloseIt(FileInformation.java:361)
art/runtime/check_jni.cc:65]   at audiobass.vx3kfile.CloseAll(vx3kfile.java:130)
art/runtime/check_jni.cc:65]   at gtc.armivx3k.prerecordplaylayout._cancelplayback_click(prerecordplaylayout.java:374)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
art/runtime/check_jni.cc:65]   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
art/runtime/check_jni.cc:65]   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
art/runtime/check_jni.cc:65]   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
art/runtime/check_jni.cc:65]   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
art/runtime/check_jni.cc:65]   at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
art/runtime/check_jni.cc:65]   at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
art/runtime/check_jni.cc:65]   at android.view.View.performClick(View.java:4780)
art/runtime/check_jni.cc:65]   at android.view.View$PerformClick.run(View.java:19866)
art/runtime/check_jni.cc:65]   at android.os.Handler.handleCallback(Handler.java:739)
art/runtime/check_jni.cc:65]   at android.os.Handler.dispatchMessage(Handler.java:95)
art/runtime/check_jni.cc:65]   at android.os.Looper.loop(Looper.java:135)
art/runtime/check_jni.cc:65]   at android.app.ActivityThread.main(ActivityThread.java:5258)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
art/runtime/check_jni.cc:65]
art/runtime/runtime.cc:298] Runtime aborting...
art/runtime/runtime.cc:298] Aborting thread:
art/runtime/runtime.cc:298] "main" prio=5 tid=1 Native
art/runtime/runtime.cc:298]   | group="" sCount=0 dsCount=0 obj=0x74c44000 self=0xf83bf810
art/runtime/runtime.cc:298]   | sysTid=29356 nice=0 cgrp=default sched=0/0 handle=0xf77c5e80
art/runtime/runtime.cc:298]   | state=R schedstat=( 18853959709 4426635910 28903 ) utm=1694 stm=191 core=0 HZ=100
art/runtime/runtime.cc:298]   | stack=0xff177000-0xff179000 stackSize=8MB
art/runtime/runtime.cc:298]   | held mutexes= "abort lock" "mutator lock"(shared held)
art/runtime/runtime.cc:298]   native: #00 pc 00005f8b  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+91)
art/runtime/runtime.cc:298]   native: #01 pc 00003052  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+34)
art/runtime/runtime.cc:298]   native: #02 pc 0039cbe8  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+136)
art/runtime/runtime.cc:298]   native: #03 pc 0036703b  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+267)
art/runtime/runtime.cc:298]   native: #04 pc 0034be6b  /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*) (.isra.147)+59)
art/runtime/runtime.cc:298]   native: #05 pc 0034c2b1  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+705)
art/runtime/runtime.cc:298]   native: #06 pc 0034c4be  /system/lib/libart.so (art::Runtime::Abort()+126)
art/runtime/runtime.cc:298]   native: #07 pc 000eb174  /system/lib/libart.so (art::LogMessage::~LogMessage()+1876)
art/runtime/runtime.cc:298]   native: #08 pc 001021a5  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1989)
art/runtime/runtime.cc:298]   native: #09 pc 001029df  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+111)
art/runtime/runtime.cc:298]   native: #10 pc 00106c01  /system/lib/libart.so (art::ScopedCheck::Check(bool, char const*, ...) (.constprop.130)+1057)
art/runtime/runtime.cc:298]   native: #11 pc 0011865b  /system/lib/libart.so (art::CheckJNI::DeleteGlobalRef(_JNIEnv*, _jobject*)+123)
art/runtime/runtime.cc:298]   native: #12 pc 0000ece7  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/runtime.cc:298]   native: #13 pc 0000ed17  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/runtime.cc:298]   native: #14 pc 00026184  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)
art/runtime/runtime.cc:298]   native: #15 pc 00028499  /data/app/gtc.armivx3k-2/lib/x86/libbass.so (???)


I even try to secure my code , I checked for Bass_ChannelGetInfo first, to get True / False result. If true , then I execute Bass_StreamFree on handle.
Code: [Select]
public void CloseIt() {
if (handle != 0) {
BASS.BASS_CHANNELINFO chinfo = new BASS.BASS_CHANNELINFO();
if (BASS.BASS_ChannelGetInfo(handle, chinfo)) {
// handle masih valid
bassloader.BASS_StreamFree(handle);
}
}
handle = 0;
}


Yet above crash may sometimes happened.
If it happened everytime, better for me to troubleshoot... but it happened on random, makes difficult to check which code is wrong.

BASS version is : 2040e15

Please advice.

Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: StreamFree crash
« Reply #1 on: 17 Oct '19 - 14:53 »
The crash happened when deleting a reference to a Java DSPPROC callback function because the reference was no longer valid. It looks like that could possibly happen if BASS_ChannelRemoveDSP was called just before BASS_StreamFree was. Here's an update for you to try:

   www.un4seen.com/stuff/bass-android-test.zip

Let me know if you still see the problem happen with that.

rdkartono

  • Posts: 33
Re: StreamFree crash
« Reply #2 on: 18 Oct '19 - 04:26 »
Good Morning,

I updated bass library with  bass-android-test.zip, bass version now 2040e16

and regarding your examination
Quote
It looks like that could possibly happen if BASS_ChannelRemoveDSP was called just before BASS_StreamFree was

I did some modification to my code.
Previously : ChannelStop, ChannelRemoveDSP, StreamFree..
Now : ChannelRemoveDSP, ChannelStop, StreamFree.

Then until several tests , didn't get crashed.

Thank you


rdkartono

  • Posts: 33
Re: StreamFree crash
« Reply #3 on: 3 Dec '19 - 03:33 »
Sorry for waking up old thread again....

Following this thread : http://www.un4seen.com/forum/?action=post;quote=131124;topic=18515.0;last_msg=131127
I re-download bass android today, and found that official release of bass android Version : 2040e15
The test bass you gave me, 2040e16, was fine.

So this crash happened again.

Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: StreamFree crash
« Reply #4 on: 3 Dec '19 - 16:30 »
Yes, the release version hasn't been updated yet. That should finally happen very soon now.