是什么原因导致了Android的Dalvik java.lang.VerifyError"无效寄存器类型数组索引"? [英] What causes the Android Dalvik java.lang.VerifyError "Invalid reg type for array index"?

查看:1199
本文介绍了是什么原因导致了Android的Dalvik java.lang.VerifyError"无效寄存器类型数组索引"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级我用它来构建一个应用程序从19.1.0至21.0.2 Android的构建工具。该应用程序编译,但是当我启动它,我得到这个错误:

I have recently upgraded the Android build tools I use to build an app from 19.1.0 to 21.0.2. The app compiles, but when I start it I get this error:

net.i2p.android W/dalvikvm﹕ Invalid reg type for array index (1103759864)
net.i2p.android W/dalvikvm﹕ VFY:  rejected Lnet/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement;.multiply (Lnet/i2p/crypto/eddsa/math/FieldElement;)Lnet/i2p/crypto/eddsa/math/FieldElement;
net.i2p.android W/dalvikvm﹕ VFY:  rejecting opcode 0x44 at 0x001c
net.i2p.android W/dalvikvm﹕ VFY:  rejected Lnet/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement;.multiply (Lnet/i2p/crypto/eddsa/math/FieldElement;)Lnet/i2p/crypto/eddsa/math/FieldElement;
net.i2p.android W/dalvikvm﹕ Verifier rejected class Lnet/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement;
net.i2p.android W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lnet/i2p/crypto/eddsa/spec/EdDSANamedCurveTable;
net.i2p.android W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lnet/i2p/crypto/SigType;
net.i2p.android W/dalvikvm﹕ Exception Ljava/lang/VerifyError; thrown while initializing Lnet/i2p/router/startup/CreateRouterInfoJob;
net.i2p.android W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0x41caeda0)
net.i2p.android E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-6713
    Process: net.i2p.android, PID: 26198
    java.lang.VerifyError: net/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement
            at net.i2p.crypto.eddsa.math.ed25519.Ed25519LittleEndianEncoding.decode(Ed25519LittleEndianEncoding.java:189)
            at net.i2p.crypto.eddsa.math.Field.fromByteArray(Field.java:55)
            at net.i2p.crypto.eddsa.math.Field.<init>(Field.java:39)
            at net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable.<clinit>(EdDSANamedCurveTable.java:21)
            at net.i2p.crypto.SigType.<clinit>(SigType.java:51)
            at net.i2p.router.startup.CreateRouterInfoJob.<clinit>(CreateRouterInfoJob.java:54)
            at net.i2p.router.KeyManager$SynchronizeKeysJob.syncKeys(KeyManager.java:156)
            at net.i2p.router.KeyManager$SynchronizeKeysJob.runJob(KeyManager.java:146)
            at net.i2p.router.KeyManager.startup(KeyManager.java:65)
            at net.i2p.router.Router.runRouter(Router.java:468)
            at net.i2p.router.Router.main(Router.java:1158)
            at net.i2p.router.RouterLaunch.main(RouterLaunch.java:21)
            at net.i2p.android.router.service.RouterService$Starter.run(RouterService.java:320)
            at java.lang.Thread.run(Thread.java:841)

我运行在同一台设备上的应用程序,并没有改变任何code。为什么现在Dalvik的拒绝这个类呢?我在网上搜索,但没有发现任何有关数组下标。

被拒绝类的源$ C ​​$ c是<一个href="https://github.com/str4d/ed25519-java/blob/8253fbe71400d3fcb659dac720f00deb58ed4e2e/src/net/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement.java"相对=nofollow>这里。

The source code of the rejected class is here.

推荐答案

我找不到在构建工具,浮出水面的问题,具体的变化,但在看的的答案,不同的Dalvik问题,我想通了错误。

I can't find the specific change in the build tools that surfaced the problem, but after looking at the answer to a different Dalvik problem, I figured out the error.

Dalvik的拒绝<一href="https://github.com/str4d/ed25519-java/blob/8253fbe71400d3fcb659dac720f00deb58ed4e2e/src/net/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement.java#L218"相对=nofollow> Ed25519FieldElement.multiply() ,因为它包含155局部变量。这种方法是由相应的C code直接移植,并没有很好地转化为Java字节code。这似乎与19.1.0和21.0 +,编译器在编译工具是在某种程度上改变了prevents的Dalvik从处理这么多的局部变量。

Dalvik rejects Ed25519FieldElement.multiply() because it contains 155 local variables. This method was directly ported from corresponding C code, and does not translate well into Java bytecode. It would seem that between 19.1.0 and 21.0.+, the compiler in the build tools was changed in a way that prevents Dalvik from handling this many local variables.

最后的后该页面提供了一些额外的观点:

The last post on this page provides some additional insight:

是的,在Dalvik编译器试图分配一个注册到每一个   在该方法的局部变量。它应该能够处理很多,   但显然不能。通过使它们的实例变量删除   编译器的需求/欲望管理他们(也使该方法   一个相当小)。

Yep, the Dalvik compiler attempts to assign a "register" to every local variable in the method. It should be able to handle that many, but apparently can't. By making them instance variables you remove the compiler's need/desire to "manage" them (and also make the method a fair amount smaller).

我的解决办法是消除不必要的20变量(无操作任务如 G0 = G [0] ),并直接使用,而不是阵列。这确实会增加将来的错误蔓延到了code(如果数组索引中的一个意外改变)的可能性,但降低了局部变量的数量,以135解决了运行时类排斥反应。

My solution was to remove twenty unnecessary variables (the no-op assignments like g0 = g[0]), and instead using the arrays directly. This does increase the likelihood of a future bug creeping into the code (if one of the array indices is changed accidentally), but reducing the number of local variables to 135 resolved the runtime class rejection.

的正确的解决方案是重构方法完全以减少其长度。这必须格外小心,以避免导入侧信道攻击向量的。

The "correct" solution would be to refactor the method entirely to reduce its length. This must be done with care, to avoid introducing side-channel attack vectors.

这篇关于是什么原因导致了Android的Dalvik java.lang.VerifyError&QUOT;无效寄存器类型数组索引&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆