I am writing instrumentation on Dalvik bytecode which performs some logging for various method call entries. Specifically, at various method call sites, I will insert a set of instructions which collects up the parameters, puts them in an Object[]
array, and then passes that to a logging function.
This is all fine and well, I have implemented and gotten past all of the kludges for most apps. But I'm encountering one particularly impenetrable Dalvik verifier error:
java.lang.VerifyError: Verifier rejected class io.a.a.g: void io.a.a.g.r()
failed to verify: void io.a.a.g.r(): [0x570] register v5 has type Reference:
java.lang.Object but expected Precise Reference: java.lang.String
I looked at the code that is being generated by my instrumentation, and all I'm doing is putting register v5 in an array of objects.
I have a few questions here:
- What is a precise reference, and why is it incompatible with references?
- What does the offset here mean?
[0x570]
points into the middle of a bytecode instruction, so it doesn't clearly map to any instructions: the instructions around there don't involvev5
. - How would I go about debugging this? Ideally, I'd like to know what the verifier thinks should be happening and fix that.
EDIT:
Here's a dump of the bytecode of the method I'm speaking about. https://gist.github.com/kmicinski/c8382f0521b19643bb24379d91c47d36 As you can see, 0x570 isn't the beginning of an instruction, and (as far as I can tell) there isn't any place where r5 conflicts with a String where it should be an object.