InternalError: Bad rare toggle magic - what does that mean?
Today I have a stacktrace with a very strange error. In fact, I may be the first to ever get this (YAY!), Since prior to posting this question, the only cases of "bad rare switch magic" on Google are in the Android source code.
Here's the stacktrace part (Android 2.3.4):
java.lang.InternalError: bad sparse switch magic at org.my.app.MyItemAdapter.(MyItemAdapter.java:64) at org.my.app.MyActivity.onCreate(MyActivity.java:78)
An error occurred while exiting the MyItemAdapter constructor. Since it is internal, I'm pretty sure it's not my fault, but I just would like to know what went wrong in the Dalvik VM.
This error seems to be instruction-related
, just for clarification - I didn't use it directly in the MyItemAdapter constructor. To figure out what went wrong I will probably have to go through a lot of dalwick related code, so I ask you - is there someone who can explain to me what went wrong? I'm just curious.
Here is the Android code snippet that is causing this error: http://androidxref.com/source/xref/dalvik/vm/interp/Interp.cpp#1070
source to share
There is a decrypted sparse switch dex code that points to the Android interpreter in a region of memory that is not actually a sparse switch operator.
Dex byte code can represent two types of switch statements: packed or sparse. A packed switch operation should only store the lowest value to turn on. Each subsequent switch value is incremented by one from the previous value, so the case statements store only the branch target in byte code. The sparse switch format has an entry for a single value and a branch target for a case statement. See the "sparse-payload" section in the "Bytecode for Dalvik VM" document ( http://source.android.com/tech/dalvik/dalvik-bytecode.html ).
Rare switch statements in dex are denoted by the noop byte code command with the second byte 0x02 ( http://androidxref.com/source/xref/dalvik/libdex/DexOpcodes.h#53 ). The first byte of the noop command is always 0x00, so the full magic signature of the sparse switch statement is 0x0200.
The dex byte code command to actually execute a sparse switch statement is called a sparse key. This code is 0x2c, and it also accepts a register to check for a switch statement and a switch table address . I believe the address of the switch table in your dex file is wrong. Without additional information, it would be difficult to say why.
source to share