美文网首页
JNI开发报错 JNI DETECTED ERROR IN AP

JNI开发报错 JNI DETECTED ERROR IN AP

作者: 夏_Leon | 来源:发表于2019-12-02 15:05 被阅读0次

在之前用JNI进行AES加密中,发现偶发bug,报错信息清理如下:

2019-07-05 15:46:06.706 A/art: art/runtime/java_vm_ext.cc:496] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal continuation byte 0xea
2019-07-05 15:46:06.706 A/art: art/runtime/java_vm_ext.cc:496]     string: '{"header":{"orgCode":"shanshancar_Android","transDate":"2019-07-05 15:46:06","tr����,�w6��D��ώ  �.��1=����Y�����=6  <�;.�Т��[gH�����V���v��%��`v4~;E�G�T����_<r������>��L��҆��g�����q��Cg&��������a�#-?��%��q/�ax���T�����m�4����O7`_��-P�����I�P�?GC8�tK������@��3��w���.����˰����Į���풇1����>�������Pe���p�i�����_HÀ�
2019-07-05 15:46:06.706 A/art: art/runtime/java_vm_ext.cc:496] �g�_�Jt� ����y��׿����%AxJ5�������
2019-07-05 15:46:06.706 A/art: art/runtime/java_vm_ext.cc:496] �����!���ݴ$���=<�KC�F�̔�C.|��~Õ�'
2019-07-05 15:46:06.706 A/art: art/runtime/java_vm_ext.cc:496]     input: '0x7b 0x22 0x68 0x65 0x61 0x64 0x65 0x72 0x22 0x3a 0x7b 0x22 0x6f 0x72 0x67 0x43 0x6f 0x64 0x65 0x22 0x3a 0x22 0x73 0x68 0x61 0x6e 0x73 0x68 0x61 0x6e 0x63 0x61 0x72 0x5f 0x41 0x6e 0x64 0x72 0x6f 0x69 0x64 0x22 0x2c 0x22 0x74 0x72 0x61 0x6e 0x73 0x44 0x61 0x74 0x65 0x22 0x3a 0x22 0x32 0x30 0x31 0x39 0x2d 0x30 0x37 0x2d 0x30 0x35 0x20 0x31 0x35 0x3a 0x34 0x36 0x3a 0x30 0x36 0x22 0x2c 0x22 0x74 0x72 0xed <0xea> 0xe8 0xc7 0x2c 0x1e 0x77 0x36 0xb8 0x8b 0x44 0x17 0x8a 0xcf 0x8e 0x09 0x9c 0x2e 0x01 0x18 0x31 0x3d 0x1f 0x16 0x82 0xea 0xb8 0x59 0x95 0xd1 0xce 0x0f 0x8c 0x3d 0x36 0x09 0x3c 0xf5 0x3b 0x2e 0xd6 0xd0 0xa2 0xb0 0x99 0x5b 0x67 0x48 0xef 0x0f 0x1a 0x9d 0xaa 0x56 0xb8 0x89 0x1e 0x76 0x85 0x18 0x25 0xd1 0xd6 0x60 0x76 0x34 0x7e 0x3b 0x45 0x14 0x47 0x0c 0xc1 0x54 0xf2 0x9a 0xc0

后发现是在JNI的AES加密,在并发的时候,会造成内存错乱,目前没找到在并发加解密下完美运行的办法。暂且在调用方法且加入synchronize字段,保证线程安全。
具体就是把

public static String myEncrypt(String src)

public static String myDecrypt(String str)

改为

public synchronized static String myEncrypt(String src)

public synchronized static String myDecrypt(String str)

相关文章

网友评论

      本文标题:JNI开发报错 JNI DETECTED ERROR IN AP

      本文链接:https://www.haomeiwen.com/subject/fzsehctx.html