how to disable dexopt?

4,164 views
Skip to first unread message

Bytec0d3

unread,
Feb 18, 2011, 8:21:06 AM2/18/11
to android-platform
Hi all,
i'm trying to disable dexopt on the emulator to test the execution of
a corrupted dex file.
I've tried this:

adb shell setprop dalvik.vm.dexopt-flags v=n
adb shell stop; adb shell start

adb shell getprop | grep dalvik
[dalvik.vm.dexopt-flags]: [v=n]


but when i lunch the .jar file with

adb shell dalvikvm -cp /mnt/sdcard/Test.jar Test ,dexopt seems still
to be launched:

D/dalvikvm( 337): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm( 337): ODEX file is stale or bad; removing and retrying (/
data/dalvik-cache/mnt@sdcard@Test...@classes.dex)
D/dalvikvm( 337): DexOpt: --- BEGIN 'Test.jar' (bootstrap=0) ---
E/dalvikvm( 338): Bogus size for section: got 0xe; expected 0x16ac
E/dalvikvm( 338): Swap of section type 0001 failed
E/dalvikvm( 338): ERROR: Byte swap + verify failed
E/dalvikvm( 338): Optimization failed
W/dalvikvm( 337): DexOpt: --- END 'Test.jar' --- status=0xff00,
process failed
E/dalvikvm( 337): Unable to extract+optimize DEX from 'Test.jar'
W/dalvikvm( 337): threadid=1: thread exiting with uncaught exception
(group=0x40015560)

I get the same error if i launch the command:

adb shell dalvikvm -Xverify:none -Xdexopt:none -cp /mnt/sdcard/
Test.jar Test

so how can i disable dexopt?

Thanks in advance.

Dianne Hackborn

unread,
Feb 18, 2011, 9:03:28 PM2/18/11
to android-...@googlegroups.com
It is required.  This isn't just optional optimization; this does the final linking of the .dex file for the target device before it can be run.


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Mattia Campana

unread,
Feb 19, 2011, 4:37:08 AM2/19/11
to android-...@googlegroups.com
Thx, but i've read this from the documentation ("embedded-vm-control.html"):

"You could also set dalvik.vm.dexopt-flags to v=n to have the framework pass -Xverify:none -Xdexopt:verified to disable verification. (We could pass in -Xdexopt:all to allow optimization, but that wouldn't necessarily optimize more of the code, since classes that fail verification may well be skipped by the optimizer for the same reasons.) Classes will not be verified by dexopt, and unverified code will be loaded and executed."

Btw, theese options don't work for me :(

Mattia Campana

unread,
Feb 21, 2011, 9:19:50 AM2/21/11
to android-...@googlegroups.com
If it is required, why in $ANDROID_SOURCE/dalvik/docs/embedded-vm-control.html is explained how to disable it?
Btw, the commands recommended in the documentation do not seem to work.


Il giorno 19/feb/2011, alle ore 03.03, Dianne Hackborn ha scritto:

Tez

unread,
Feb 21, 2011, 10:10:16 AM2/21/11
to android-platform
according to dalvik docs, optimization is always performed. the
controls are just for verification.
if build time optimization is not done, it will occur at install time.

On Feb 21, 3:19 pm, Mattia Campana <bytec...@gmail.com> wrote:
> If it is required, why in $ANDROID_SOURCE/dalvik/docs/embedded-vm-control.html is explained how to disable it?
> Btw, the commands recommended in the documentation do not seem to work.
>
> Il giorno 19/feb/2011, alle ore 03.03, Dianne Hackborn ha scritto:
>
> > It is required.  This isn't just optional optimization; this does the final linking of the .dex file for the target device before it can be run.
>
> > On Fri, Feb 18, 2011 at 5:21 AM, Bytec0d3 <bytec...@gmail.com> wrote:
> > Hi all,
> > i'm trying to disable dexopt on the emulator to test the execution of
> > a corrupted dex file.
> > I've tried this:
>
> > adb shell setprop dalvik.vm.dexopt-flags v=n
> > adb shell stop; adb shell start
>
> > adb shell getprop | grep dalvik
> > [dalvik.vm.dexopt-flags]: [v=n]
>
> > but when i lunch the .jar file with
>
> > adb shell dalvikvm -cp /mnt/sdcard/Test.jar Test ,dexopt seems still
> > to be launched:
>
> > D/dalvikvm(  337): DexOpt: incorrect opt magic number (0xff ff ff ff)
> > D/dalvikvm(  337): ODEX file is stale or bad; removing and retrying (/
> > data/dalvik-cache/mnt@sdc...@Test.jar@classes.dex)
> > D/dalvikvm(  337): DexOpt: --- BEGIN 'Test.jar' (bootstrap=0) ---
> > E/dalvikvm(  338): Bogus size for section: got 0xe; expected 0x16ac
> > E/dalvikvm(  338): Swap of section type 0001 failed
> > E/dalvikvm(  338): ERROR: Byte swap + verify failed
> > E/dalvikvm(  338): Optimization failed
> > W/dalvikvm(  337): DexOpt: --- END 'Test.jar' --- status=0xff00,
> > process failed
> > E/dalvikvm(  337): Unable to extract+optimize DEX from 'Test.jar'
> > W/dalvikvm(  337): threadid=1: thread exiting with uncaught exception
> > (group=0x40015560)
>
> > I get the same error if i launch the command:
>
> > adb shell dalvikvm -Xverify:none -Xdexopt:none -cp /mnt/sdcard/
> > Test.jar Test
>
> > so how can i disable dexopt?
>
> > Thanks in advance.
>
> > --
> > You received this message because you are subscribed to the Google Groups "android-platform" group.
> > To post to this group, send email to android-...@googlegroups.com.
> > To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com

Mattia Campana

unread,
Feb 21, 2011, 11:10:09 AM2/21/11
to android-...@googlegroups.com
Thx for the reply,
my goal is to disable the .dex verification to test the execution of a corrupted file.
If the verification is always performed, I don't understand the value of the specified commands in embedded-vm-control doc:

"You could also set dalvik.vm.dexopt-flags to v=n to have the framework pass -Xverify:none -Xdexopt:verified to disable verification. (We could pass in -Xdexopt:all to allow optimization, but that wouldn't necessarily optimize more of the code, since classes that fail verification may well be skipped by the optimizer for the same reasons.) Classes will not be verified by dexopt, and unverified code will be loaded and executed."

So, if i send the command:

"setprop dalvik.vm.dexopt-flags v=n,o=n"

or

"dalvikvm -Xverify: none -Xdexopt:none -cp MyJar.jar MyClass"

i can't understand why the dex verification continues to be performed.

Thanks in advance.

fadden

unread,
Feb 22, 2011, 1:55:26 PM2/22/11
to android-platform
On Feb 21, 8:10 am, Mattia Campana <bytec...@gmail.com> wrote:
> my goal is to disable the .dex verification to test the execution of a corrupted file.
> If the verification is always performed, I don't understand the value of the specified commands in embedded-vm-control doc:

There are multiple stages.

The DEX loader is performing some basic structural checks. On a big-
endian system it would also be byte-swapping values at this time.
There is no way to disable this, because it indicates that the file is
unparseable.

The error you're getting:

E/dalvikvm( 338): Bogus size for section: got 0xe; expected 0x16ac
E/dalvikvm( 338): Swap of section type 0001 failed
E/dalvikvm( 338): ERROR: Byte swap + verify failed

says that the file structure is damaged. Attempting to continue would
likely result in a VM crash.

The dalvik.vm.dexopt-flags property and the -Xverify command-line
option control bytecode verification. Once the DEX file has been
determined to be structurally sound, a second pass is done to make
sure that the bytecode in individual classes and methods represents a
valid Dalvik program.

Mattia Campana

unread,
Feb 22, 2011, 2:40:31 PM2/22/11
to android-...@googlegroups.com
Thanks a lot, now everything is clearer :P

Reply all
Reply to author
Forward
0 new messages