关闭

关于:JNI WARNING: illegal start byte 处理

标签: jnibytestringnull虚拟机user
3529人阅读 评论(3) 收藏 举报
分类:

W/dalvikvm( 1473): JNI WARNING: illegal start byte 0xfb
W/dalvikvm( 1473):              string: '' 大宦飞懧?
W/dalvikvm( 1473):              in Landroid/media/MediaScanner;.processFile (Ljava/lang/String;Ljava/lang/String;Landroid/media/MediaScannerClient;)V (NewStringUTF)
I/dalvikvm( 1473): "MediaScannerService" prio=5 tid=10 NATIVE
I/dalvikvm( 1473):   | group="main" sCount=0 dsCount=0 s=N obj=0x45f1ea18 self=0x22f0d0
I/dalvikvm( 1473):   | sysTid=1647 nice=11 sched=3/0 cgrp=unknown handle=2229456
I/dalvikvm( 1473):   at android.media.MediaScanner.processFile(Native Method)
I/dalvikvm( 1473):   at android.media.MediaScanner.access$500(MediaScanner.java:103)
I/dalvikvm( 1473):   at android.media.MediaScanner$MyMediaScannerClient.doScanFile(MediaScanner.java:565)
I/dalvikvm( 1473):   at android.media.MediaScanner$MyMediaScannerClient.scanFile(MediaScanner.java:497)
I/dalvikvm( 1473):   at android.media.MediaScanner.processDirectory(Native Method)
I/dalvikvm( 1473):   at android.media.MediaScanner.scanDirectories(MediaScanner.java:1275)
I/dalvikvm( 1473):   at com.android.providers.media.MediaScannerService.scan(MediaScannerService.java:111)
I/dalvikvm( 1473):   at com.android.providers.media.MediaScannerService.access$200(MediaScannerService.java:48)
I/dalvikvm( 1473):   at com.android.providers.media.MediaScannerService$ServiceHandler.handleMessage(MediaScannerService.java:268)
I/dalvikvm( 1473):   at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm( 1473):   at android.os.Looper.loop(Looper.java:123)
I/dalvikvm( 1473):   at com.android.providers.media.MediaScannerService.run(MediaScannerService.java:188)
I/dalvikvm( 1473):   at java.lang.Thread.run(Thread.java:1096)
I/dalvikvm( 1473):
E/dalvikvm( 1473): VM aborting

 

 

造成该问题的原因是没有通过虚拟机的checkjni检查。代码在dalvik/vm/CheckJni.c

 

/*
 * Verify that "bytes" points to valid "modified UTF-8" data.
 */
static void checkUtfString(JNIEnv* env, const char* bytes, bool nullOk,
    const char* func)
{
    const char* origBytes = bytes;

    if (bytes == NULL) {
        if (!nullOk) {
            LOGW("JNI WARNING: unexpectedly null UTF string/n");
            goto fail;
        }

        return;
    }

    while (*bytes != '/0') {
        u1 utf8 = *(bytes++);
        // Switch on the high four bits.
        switch (utf8 >> 4) {
            case 0x00:
            case 0x01:
            case 0x02:
            case 0x03:
            case 0x04:
            case 0x05:
            case 0x06:
            case 0x07: {
                // Bit pattern 0xxx. No need for any extra bytes.
                break;
            }
            case 0x08:
            case 0x09:
            case 0x0a:
            case 0x0b:
            case 0x0f: {
                /*
                 * Bit pattern 10xx or 1111, which are illegal start bytes.
                 * Note: 1111 is valid for normal UTF-8, but not the
                 * modified UTF-8 used here.
                 */
                LOGW("JNI WARNING: illegal start byte 0x%x/n", utf8);
                goto fail;
            }
            case 0x0e: {
                // Bit pattern 1110, so there are two additional bytes.
                utf8 = *(bytes++);
                if ((utf8 & 0xc0) != 0x80) {
                    LOGW("JNI WARNING: illegal continuation byte 0x%x/n", utf8);
                    goto fail;
                }
                // Fall through to take care of the final byte.
            }
            case 0x0c:
            case 0x0d: {
                // Bit pattern 110x, so there is one additional byte.
                utf8 = *(bytes++);
                if ((utf8 & 0xc0) != 0x80) {
                    LOGW("JNI WARNING: illegal continuation byte 0x%x/n", utf8);
                    goto fail;
                }
                break;
            }
        }
    }

    return;

fail:
    LOGW("             string: '%s'/n", origBytes);
    showLocation(dvmGetCurrentJNIMethod(), func);
    abortMaybe();
}

 

解决方法:

是否进行checkjni检查是由ro.kernel.android.checkjni决定。

在eng版本中ro.kernel.android.checkjni=1.而在user版本不做检查。

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:143719次
    • 积分:1747
    • 等级:
    • 排名:千里之外
    • 原创:16篇
    • 转载:61篇
    • 译文:1篇
    • 评论:74条
    文章分类
    最新评论