RWops - Android 4.4 KitKat + ART issue

Hello folks,

apparently there seems to be some kind of problem with RWops on Android 4.4 with ART (not Dalvik), when my application try to read a file inside assets directory it throws an error:

F/art ( 5381): art/runtime/check_jni.cc:64] JNI DETECTED ERROR IN APPLICATION: capacity must be greater than 0: 0
F/art ( 5381): art/runtime/check_jni.cc:64] in call to NewDirectByteBuffer
F/art ( 5381): art/runtime/check_jni.cc:64] from void org.libsdl.app.SDLActivity.nativeInit()
F/art ( 5381): art/runtime/check_jni.cc:64] “SDLThread” prio=5 tid=14 Runnable
F/art ( 5381): art/runtime/check_jni.cc:64] | group=“main” sCount=0 dsCount=0 obj=0x64d732b8 self=0x47255958
F/art ( 5381): art/runtime/check_jni.cc:64] | sysTid=5399 nice=0 cgrp=apps sched=0/0 handle=0x47255cc0
F/art ( 5381): art/runtime/check_jni.cc:64] | state=R schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
F/art ( 5381): art/runtime/check_jni.cc:64] | stack=0x483bb000-0x483bf000 stackSize=1040KB
F/art ( 5381): art/runtime/check_jni.cc:64] native: art::Thread::DumpStack(std::ostream&) const+87 [0x4160ceac] (libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: ??? [0x414ba83e] (libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: art::JniAbortF(char const*, char const*, …)+51 [0x414bb1f4] (libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: ??? [0x414c63d8] (libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: Android_JNI_FileRead+163 [0x4822ddd0] (libSDL2.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: FileLoader::getBytes(int, unsigned char*)+49 [0x483217f2] (libmain.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: Config::loadConfFile(std::string)+115 [0x4831ef08] (libmain.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: Initialize()+247 [0x48346a68] (libmain.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: SDL_main+37 [0x4832eaea] (libmain.so)

Config + FileLoader classes are mine.

The application works fine as soon as I switch to Dalvik.

Also it is worth mentioning that along with updated NDK there seems to be a warning regarding visibility of a symbol:

/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/…/lib/gcc/arm-linux-androideabi/4.6/…/…/
…/…/arm-linux-androideabi/bin/ld.exe: warning: hidden symbol ‘__cxa_begin_cleanup’ in ./obj/local/armeabi-v7a/libgnust
l_static.a(eh_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libSDL2.so

/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/…/lib/gcc/arm-linux-androideabi/4.6/…/…/
…/…/arm-linux-androideabi/bin/ld.exe: warning: hidden symbol ‘__cxa_type_match’ in ./obj/local/armeabi-v7a/libgnustl_s
tatic.a(eh_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libSDL2.so

It seems the new VM does not like allocating a buffer of size zero. This
one in particular should be an easy fix, but I wouldn’t chase after these
bugs until they stabilize ART.

2013/11/26 .3lite > Hello folks,

apparently there seems to be some kind of problem with RWops on Android
4.4 with ART (not Dalvik), when my application try to read a file inside
assets directory it throws an error:

F/art ( 5381): art/runtime/check_jni.cc:64] JNI DETECTED ERROR IN
APPLICATION: capacity must be greater than 0: 0
F/art ( 5381): art/runtime/check_jni.cc:64] in call to NewDirectByteBuffer
F/art ( 5381): art/runtime/check_jni.cc:64] from void
org.libsdl.app.SDLActivity.nativeInit()
F/art ( 5381): art/runtime/check_jni.cc:64] “SDLThread” prio=5 tid=14
Runnable
F/art ( 5381): art/runtime/check_jni.cc:64] | group=“main” sCount=0
dsCount=0 obj=0x64d732b8 self=0x47255958
F/art ( 5381): art/runtime/check_jni.cc:64] | sysTid=5399 nice=0 cgrp=apps
sched=0/0 handle=0x47255cc0
F/art ( 5381): art/runtime/check_jni.cc:64] | state=R schedstat=( 0 0 0 )
utm=0 stm=0 core=0 HZ=100
F/art ( 5381): art/runtime/check_jni.cc:64] | stack=0x483bb000-0x483bf000
stackSize=1040KB
F/art ( 5381): art/runtime/check_jni.cc:64] native:
art::Thread::DumpStack(std::ostream&) const+87 [0x4160ceac] (libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: ??? [0x414ba83e]
(libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: art::JniAbortF(char
const*, char const*, …)+51 [0x414bb1f4] (libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: ??? [0x414c63d8]
(libart.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native:
Android_JNI_FileRead+163 [0x4822ddd0] (libSDL2.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native:
FileLoader::getBytes(int, unsigned char*)+49 [0x483217f2] (libmain.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native:
Config::loadConfFile(std::string)+115 [0x4831ef08] (libmain.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: Initialize()+247
[0x48346a68] (libmain.so)
F/art ( 5381): art/runtime/check_jni.cc:64] native: SDL_main+37
[0x4832eaea] (libmain.so)

Config + FileLoader classes are mine.

The application works fine as soon as I switch to Dalvik.

Also it is worth mentioning that along with updated NDK there seems to be
a warning regarding visibility of a symbol:

/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/…/lib/gcc/arm-linux-androideabi/4.6/…/…/
…/…/arm-linux-androideabi/bin/ld.exe: warning: hidden symbol
’__cxa_begin_cleanup’ in ./obj/local/armeabi-v7a/libgnust
l_static.a(eh_arm.o) is referenced by DSO
./obj/local/armeabi-v7a/libSDL2.so

/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/…/lib/gcc/arm-linux-androideabi/4.6/…/…/
…/…/arm-linux-androideabi/bin/ld.exe: warning: hidden symbol
’__cxa_type_match’ in ./obj/local/armeabi-v7a/libgnustl_s
tatic.a(eh_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libSDL2.so


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

Indeed, the rest seems to be working as intended plus I’ve noticed a small improvement in rendering performance due to new VM :slight_smile: