History log of /art/runtime/dex_file_verifier.h
Revision Date Author Comments
d6bcae6d82d99727150f0e3c3d9cb3e9bc739d50 03-May-2016 Vladimir Marko <vmarko@google.com> Fix ProtoId ordering check in DexFileVerifier.

The code previously checked for kNoDexIndex16 as the type
list terminator. This is incorrect as we should not actually
see the kNoDexIndex16 in type lists in supported dex files.

To make sure that we don't see kNoDexIndex16, check the size
of the arrays with documented limits, i.e. type-ids and
proto-ids, see dex_file.h. In the ProtoId ordering check,
DCHECK() that we don't encounter kNoDexIndex16 and verify
that the previous list is not longer if the current list's
elements match.

Bug: 28580925

(cherry picked from commit 0ca8add2ae34c26291694ecc784d64f0cc1c1380)

Change-Id: Ied6dcbd8d04e3dfef5695dbd9b3a30a079038b2b
3a52b22cf71446dd47cc1a2775dd0aabbf5e96f7 20-Feb-2016 Andreas Gampe <agampe@google.com> ART: Check alignment of section offsets

Make sure the sections mentioned in the header are aligned according
to the Dalvik File Format specification.

Ensure the same for annotations.

Bug: 27275385
Bug: https://code.google.com/p/android/issues/detail?id=201384

(cherry picked from commit b512c0e5da0767d00a0ee9b7201668ab9977e21b)

Change-Id: Ifdd98377f8468e78c1c2198223ad58cab302dd37
b512c0e5da0767d00a0ee9b7201668ab9977e21b 20-Feb-2016 Andreas Gampe <agampe@google.com> ART: Check alignment of section offsets

Make sure the sections mentioned in the header are aligned according
to the Dalvik File Format specification.

Ensure the same for annotations.

Bug: 27275385
Bug: https://code.google.com/p/android/issues/detail?id=201384
Change-Id: Ifdd98377f8468e78c1c2198223ad58cab302dd37
a5c4493c37806f1b027c90f5ec3fe808adfdf3fe 09-Feb-2016 Andreas Gampe <agampe@google.com> ART: Give better error messages in dex-file verifier

Try to decode field and method names when an access-flag violation
has been found. This is not guaranteed to work, if the file is
broken enough.

Bug: 27064244
Bug: 27070841

(cherry picked from commit c9f0ba1a4a2c9366ffc2dc2f9c2d8d3f09bb2112)

Change-Id: Ie913076462e958d4f21b481631bc874cf6f67c0d
c9f0ba1a4a2c9366ffc2dc2f9c2d8d3f09bb2112 09-Feb-2016 Andreas Gampe <agampe@google.com> ART: Give better error messages in dex-file verifier

Try to decode field and method names when an access-flag violation
has been found. This is not guaranteed to work, if the file is
broken enough.

Bug: 27064244
Bug: 27070841
Change-Id: Ie913076462e958d4f21b481631bc874cf6f67c0d
0f8e0723d67bd75125705b2707c36927beabd886 26-Oct-2015 Mathieu Chartier <mathieuc@google.com> Use HashMap for DexFileVerifier

Before:
2.51% std::map<unsigned int, unsigned short>::insert(...
0.72% malloc

After:
0.73% art::HashSet<std::__1::pair<unsigned int, unsigned short>::Insert(...
0.57% malloc

The allocation from HashSet is only 0.71% of the remaining 0.57% malloc time.
0.71% art::DexFileVerifier::CheckIntraSectionIterate(unsigned long, unsigned int, unsigned short)

Bug: 10921004

Change-Id: I85c60bf27fb2d9976b944fc15d8401904432dc22
1a9735701d0826adbc9d68cd3762b78f96499cfb 11-Sep-2015 Andreas Gampe <agampe@google.com> ART: Narrow parameter types.

Follow-up to e6215c0ec4b1bb71b722fdbf7e62eaf3be8a91d5. Those should
have been uint16_t.

Change-Id: I2cc13701eb937dad488bcf405a9a7b26eabb656e
e6215c0ec4b1bb71b722fdbf7e62eaf3be8a91d5 01-Sep-2015 Andreas Gampe <agampe@google.com> ART: Move access flags checking to dex file verifier

Actually implement all the access flags checking in the dex file
verifier. Add tests.

Change-Id: I8b797357831b588589d56d6e2e22f7b410f33008
a574b0e4772e57134538c3c098d7538d957edc90 05-Jun-2015 Jeff Hao <jeffhao@google.com> Make dex file verifier check for dups between direct and virtual methods.

The dex file verifier now rejects classes that have the same method index
in both direct and virtual methods.

Bug: 17878919
Change-Id: I431b4715e39ca2cce4df3ebef020b7ec0661a4c0
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
13735955f39b3b304c37d2b2840663c131262c18 08-Oct-2014 Ian Rogers <irogers@google.com> stdint types all the way!

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
d4ae41fd7a4ed711277c61c0d7fd2a3759458728 02-Sep-2014 Andreas Gampe <agampe@google.com> ART: Tighten verifier list reading and offsets

Check offsets and sizes for header entries of a dex file.

Bug: 17347459

(cherry picked from commit 78d639ef4be3ad7314846e1e6c1261d7d30f83fa)

Change-Id: Ia1727c33dea51f7a8e345f3799f1ba414708239c
78d639ef4be3ad7314846e1e6c1261d7d30f83fa 02-Sep-2014 Andreas Gampe <agampe@google.com> ART: Tighten verifier list reading and offsets

Check offsets and sizes for header entries of a dex file.

Bug: 17347459
Change-Id: Ia1727c33dea51f7a8e345f3799f1ba414708239c
bad0267eaab9d6a522d05469ff90501deefdb88b 25-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add native memory accounting through custom allocator.

Added a custom allocator that lets you pass in a special tag which
specifices where the allocation came from. This is used when
dumping. The performance overhead is low since each allocation only
does a atomic add/sub for each allocation/free.

The measurements are dumped to traces.txt during SIGQUIT.

Example output:
I/art (27274): AllocatorTagHeap active=120 max=120 total=168
I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724
I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608
I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080
I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392
I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044
I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688
I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760
I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136
I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56
I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8
I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156
I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020
I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864
I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320
I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852

Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82

(cherry picked from commit 5369c40f75fdcb1be7a7c06db212ce965c83a164)
5369c40f75fdcb1be7a7c06db212ce965c83a164 25-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add native memory accounting through custom allocator.

Added a custom allocator that lets you pass in a special tag which
specifices where the allocation came from. This is used when
dumping. The performance overhead is low since each allocation only
does a atomic add/sub for each allocation/free.

The measurements are dumped to traces.txt during SIGQUIT.

Example output:
I/art (27274): AllocatorTagHeap active=120 max=120 total=168
I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724
I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608
I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080
I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392
I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044
I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688
I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760
I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136
I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56
I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8
I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156
I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020
I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864
I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320
I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852

Bug: 16238192

Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82
5cac343e28fe28d4bc9ccc6db5cab38db1f2b59d 29-Jul-2014 Andreas Gampe <agampe@google.com> ART: Check for duplicate class definitions in dex file verifier

Reject dex files that try to define two classes with the same type id.

Bug: 16016492

(cherry picked from commit 0ba238dcc21ae3544e1e8cb5d108725db8a1c134)

Change-Id: Ie04a684b41b50313449b87c5c3574e89f800e254
0ba238dcc21ae3544e1e8cb5d108725db8a1c134 29-Jul-2014 Andreas Gampe <agampe@google.com> ART: Check for duplicate class definitions in dex file verifier

Reject dex files that try to define two classes with the same type id.

Bug: 16016492
Change-Id: I82cc99c00b3e3cb2b3d537ec14beed9049fe900f
50d1bc198b2e347d60df74c3b0c452e1f929dd2f 18-Jul-2014 Andreas Gampe <agampe@google.com> ART: Improve overflow detection in dex file verifier

Overflows were hidden by the design of the checks. Push all range
checks as lists, so we can explicitly check against the count.

Bug: 16017886
Change-Id: I0083f83006ef1e55518b0919dff319004b66dcb8
ffdf1a72132be9113c4444b5fba3e81c9050b120 18-Jul-2014 Andreas Gampe <agampe@google.com> ART: Improve overflow detection in dex file verifier

Overflows were hidden by the design of the checks. Push all range
checks as lists, so we can explicitly check against the count.

(cherry picked from commit 50d1bc198b2e347d60df74c3b0c452e1f929dd2f)

Bug: 16017886
Change-Id: I0083f83006ef1e55518b0919dff319004b66dcb8
5e31ddadd29325649260aa186e9ffa8ccdb370a2 13-Jun-2014 Andreas Gampe <agampe@google.com> ART: Clean up DexFile verifier API

Use an out arg instead of widening a return type.

Change-Id: I70744eec408b0c6f3487f168faf510869277daff
e09269ca05e3014e86198e9a2cf6092026fafefd 07-Jun-2014 Andreas Gampe <agampe@google.com> ART: Check indices in dex file verifier

The verifier did not check the indices into string, type, method
and field arrays.

Bug: 15467347
Change-Id: Ie04eb6f5a62ff528096a006fb2d3fd8f3773e0d8
8a6bbfc66e3cf01d4aa07ee08b515beee481d553 23-Jan-2014 Ian Rogers <irogers@google.com> 64bit cleanliness for the dex file verifier.

Change-Id: I08f55ca0185b8fc265afb2ca3f949c6d6ac7c5b6
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da 13-Oct-2013 Ian Rogers <irogers@google.com> Throw IOException at source of failing to open a dex file.

Before is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more
And after is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.io.IOException: Zip archive '/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar' doesn't contain classes.dex
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:268)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:235)
at dalvik.system.DexPathList.<init>(DexPathList.java:113)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:38)
at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:128)
at java.lang.ClassLoader.access$000(ClassLoader.java:65)
at java.lang.ClassLoader$SystemClassLoader.<clinit>(ClassLoader.java:81)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:137)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more

Also, move dex file verifier messages out of logs.
In the process the ClassLinker::dex_lock_ needed tidying to cover a smaller
scope. Bug 11301553.

Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543
fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d 17-Jul-2013 Brian Carlstrom <bdc@google.com> Fix multiple inclusion guards to match new pathnames

Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

The runtime, compiler, dex2oat, and oatdump now are in seperate trees
to prevent dependency creep. They can now be individually built
without rebuilding the rest of the art projects. dalvikvm and jdwpspy
were already this way. Builds in the art directory should behave as
before, building everything including tests.

Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81