History log of /art/runtime/mem_map_test.cc
Revision Date Author Comments
3c3c4a1da1e8c03e78813d175a9974fb9f1097ea 22-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Improve the region space memory mapping.

Add a region space mmap fallback when the initial address isn't
available.

Clean up around the asan-specific base address.

Add MemMap::AlignBy to align the region space base address by the
region size, which is currently required by ReadBarrierTable.

Disable some read barriers in ZygoteCompactingCollector to avoid a
DCHECK failure in LockWord::SetMarkBitState when classes are in the
forward state due to unnecessary read barriers on
SizeOf/VisitReference.

Bug: 12687968
Test: test-art-host with CC and CMS.
Test: marlin-userdebug_asan_coverage boot.
Test: angler boots with CC and CMS.

Change-Id: I70f99779df6acc1b64cab6402f3ef7c73ce5b39b
486932a225b21ffce9ba8557990d5ad4d135963d 24-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add MapAnonymous handling for null error_str

We use MapAnonymous with null error_str for app image loading when
we want to fail quickly. Also avoid doing CheckNonOverlapping in
CheckMapRequest if error_msg is null. The result from
CheckNonOverlapping is unused and CheckNonOverlapping is slow since
it creates a backtrace map.

Bug: 22858531
Bug: 26746779

(cherry picked from commit 83723aedac536fd8a3cd6e1662dbd6260e576194)

Change-Id: I0ff03a778b36303aa1e256fe7238dece5b3bbfab
83723aedac536fd8a3cd6e1662dbd6260e576194 24-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add MapAnonymous handling for null error_str

We use MapAnonymous with null error_str for app image loading when
we want to fail quickly. Also avoid doing CheckNonOverlapping in
CheckMapRequest if error_msg is null. The result from
CheckNonOverlapping is unused and CheckNonOverlapping is slow since
it creates a backtrace map.

Bug: 22858531
Bug: 26746779
Change-Id: I8605ec0b9d9ae554a4b74f2606fa7dd81ade9021
14306b8e6e9c7829a5761992d86d3d44e9a0a1cf 20-Jan-2016 Roland Levillain <rpl@google.com> Disable MemMapTest.MapAnonymousExactAddr32bitHighAddr on MIPS32.

This test case is failing on a Creator Ci20 development
board because of memory allocation limitations.

Bug: 26635783
Change-Id: I02f1012f8005fd516aac82412c71af7a4652a80c
8d02644a351ab4b868a04b0ff39727cb83f06d8c 19-Jan-2016 Roland Levillain <rpl@google.com> mem_map_test: perform null check before dereferencing a pointer.

Bug: 26635783
Change-Id: I0bd29445b322b4c16b4f85a5acd9fac403d4fb6b
16d29f8fb20d39a6e333d21b45582651832d13c2 10-Nov-2015 Mathieu Chartier <mathieuc@google.com> Don't use fixed addresses in mem map test

We obtain a valid address instead of assuming there won't be a map
there.

These checks used to be OK when we didn't start the runtime.

Change-Id: Ie636ed3773d2c0c62d87e57623ee4ce380c64db0
42bddcec51e71d206f6d3b30a881ee6c1d50a63c 10-Nov-2015 Mathieu Chartier <mathieuc@google.com> Add low_4gb support to MapFile and MapFileAtAddress

Motivation is to use this for loading app images in low 4GB at a
non fixed address.

Added test.

Bug: 22858531
Change-Id: I0f79a4a7bfbfbdfc112e41b25c8682b1fb932ab7
1e13374baf7dfaf442ffbf9809c37c131d681eaf 20-May-2015 Evgenii Stepanov <eugenis@google.com> Generalize Valgrind annotations in ART to support ASan.

Also add redzones around non-fixed mem_map(s).
Also extend -Wframe-larger-than limit to enable arm64 ASan build.

Change-Id: Ie572481a25fead59fc8978d2c317a33ac418516c
5c42c29b89286e5efa4a4613132b09051ce5945b 25-Feb-2015 Vladimir Marko <vmarko@google.com> Add support for .bss section in oat files.

Change-Id: I779b80b8139d9afdc28373f8c68edff5df7726ce
c54e12a413e16f90526318f1f466a900a717fbb0 15-Oct-2014 Mathieu Chartier <mathieuc@google.com> Change MemMap::maps_ to not be global variable

Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.

(cherry picked from commit 6e88ef6b604a7a945a466784580c42e6554c1289)

Bug: 17962201
Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962
6e88ef6b604a7a945a466784580c42e6554c1289 15-Oct-2014 Mathieu Chartier <mathieuc@google.com> Change MemMap::maps_ to not be global variable

Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
928f72bd75c385ba2708c58521171a77264d4486 10-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix things for valgrind

Wire up valgrind gtests. Add valgrind-test-art-host, currently
only depending on valgrind-test-art-host-gtest32.

Fix an Alloc setting to allow running valgrind.

Refactor the fault handler to manage (and correctly release) the
handlers.

Fix minor failure-case leaks exposed by tests.

Failing tests:

The optimizing compiler is leaking non-arena-ed structures
(e.g., assembler buffers), as code generators are not destroyed.
The solution has been moved to a follow-up CL.

Note: All 64b tests are failing as we cannot allocate a heap.

Change-Id: I7f854cfd098d9f68107ce492363e7dba9a82b9fa
859c255c310ee0682f635fc5b1824bc72b8a1aa2 11-Jun-2014 Douglas Leung <douglas@mips.com> Fix mem_map_test for Mips.

Mips' kuseg window is from 0x0 to 0x80000000.

Change-Id: I3e90b04030672c003cdb4f7e9cda414b673b2d04
Signed-off-by: Douglas Leung <douglas@mips.com>
3eed93dd5be03e5539827bebf0f414251a12e15e 04-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Verify there's no mem map gap for immune region not to break.

This adds code that verifies that there's no memory map gap between
the image space and the main space so that the immune region
functionality won't silently break. For example, if there's a gap and
a large object is allocated in that gap, the large object is
incorrectly part of the immune region and the marking breaks.

Bug: 14059466
Change-Id: Ie6ed82988d74b6d0562ebbbaac96ee43c15b14a6
d8f26dbebe72c1cbdfa85bdeeb003283c7435db3 20-May-2014 Andreas Gampe <agampe@google.com> ART: Randomize mem_map start address for linear scan search

When using linear scan for mem_map, randomize the start of the
search with getauxval(AT_RANDOM).

Change-Id: Id1e4c86b928147d74b9b0b73ff704de5d87b4500
700a402244a1a423da4f3ba8032459f4b65fa18f 20-May-2014 Ian Rogers <irogers@google.com> Now we have a proper C++ library, use std::unique_ptr.

Also remove the Android.libcxx.mk and other bits of stlport compatibility
mechanics.

Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
507dfdd147c97bfbadebfd63584d094b6a4e7b47 16-May-2014 Ian Rogers <irogers@google.com> Compatibility layer to transition from UniquePtr to std::unique_ptr.

Use ART_WITH_STLPORT (enabled for the target) to cause the use of UniquePtr,
for the host switch to std::unique_ptr. For now the type remains called
UniquePtr.
Make dalvik compile with clang on the host, move its build to C++11.

Change-Id: I5ba8d2757904bc089ed62047ea03de3c0853fb12
84d49ccd79088eb9a9f423c0a96e3905468cfe7d 24-Apr-2014 Qiming Shi <qiming.shi@intel.com> ART: Resolve MAP_32BIT limitation in x86_64

Add checks that ensure when low4gb is set and an expected pointer
is given the requested memory fits into 4GB.

On x86_64, only use MAP_32BIT when there is no expected pointer.
This avoids a limitation in mmap (only 2GB visible).

Add tests to check behavior.

Original Author: Qiming Shi <qiming.shi@intel.com>
Change-Id: Ia2e3e0a46764ef70126b0c264f1fae681622d3cb
4fb5df8453367aa3f160ac230c03a7a98a28e562 13-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Make MemMap::MapAnonymous() fail if the requested address is not available.

Change MapAnonymous() so that a requested address vs. actual map
address mismatch will cause a failure. The existing MapAnonymous()
call sites do not check this. This should prevent potential rare case
bugs where mmap does not happen to map a region at an specified
address.

There's a potential bug that if MapAnonymous() does not guarantee the
requested address (and there's a gap between the image/oat files and
the zygote/malloc space), then GC could in theory allocate a large
object space in the gap. This would break the GC notion of the immune
space. This change will prevent this by causing all non-moving spaces
to be (really) adjacent, with no gaps in between, which CL 87711
missed.

Change-Id: Id4adb0e30adbad497334d7e00def4c0c66b15719
ef7d42fca18c16fbaf103822ad16f23246e2905d 06-Jan-2014 Ian Rogers <irogers@google.com> Object model changes to support 64bit.

Modify mirror objects so that references between them use an ObjectReference
value type rather than an Object* so that functionality to compress larger
references can be captured in the ObjectRefererence implementation.
ObjectReferences are 32bit and all other aspects of object layout remain as
they are currently.

Expand fields in objects holding pointers so they can hold 64bit pointers. Its
expected the size of these will come down by improving where we hold compiler
meta-data.
Stub out x86_64 architecture specific runtime implementation.
Modify OutputStream so that reads and writes are of unsigned quantities.
Make the use of portable or quick code more explicit.
Templatize AtomicInteger to support more than just int32_t as a type.
Add missing, and fix issues relating to, missing annotalysis information on the
mutator lock.
Refactor and share implementations for array copy between System and uses
elsewhere in the runtime.
Fix numerous 64bit build issues.

Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
fd7e7f1253927c8d7f17e7cbc259daaf51868bd3 22-Oct-2013 Hiroshi Yamauchi <yamauchi@google.com> Fix a double unmap issue in MemMap::UnMapAtEnd().

MemMap::UnMapAtEnd() unmaps the unused tail of the alloc space during
a zygote fork. But it can cause the same tail region of the memory to
be unmapped twice (once in UnMapAtEnd() and once more in ~MemMap()
during a shutdown.)

I encountered a crash because of this issue in SpaceTest.ZygoteTest
(which happens to happen only on a device in a branch with the
rosalloc change probably due to some randomness in mmap address
choice, etc.)

Here's what happens:

1) CreateZygoteSpace() will call UnMapAtEnd() and unmap the unused
tail of the alloc space.

2) In the same function, after UnMapAtEnd(), several libc new/malloc
allocations, including a new DlMallocSpace object, happen. This
happens to cause libc to map a new memory region that overlaps with
the memory region that has just been unmapped in 1) and use it to
allocate those allocations (that is, the new DlMallocSpace object is
allocated in that memory region.) This is a second DlMallocSpace that
becomes the new alloc space after zygote fork. The first DlMallocSpace
becomes the zygote space. Note that that libc maps that memory region
before the underlying memory of the second DlMallocSpace is mapped.

3) During a Runtime shutdown (which happens once for a normal VM
shutdown or at the end of each test run) all the spaces get destructed
including the the two DlMallocSpaces one by one. When the first
DlMallocSpace gets destructed (note the space list is sorted by
address,) its super destructor ~MemMap() unmaps the original memory
region that's already partially unmapped in 2). Now this memory region
includes the libc memory region that includes the second DlMallocSpace
object.

4) When the second DlMallocSpace object gets attempted to be
destructed, the memory in which the object resides is already unmapped
in 3) and causes a SIGSEGV.

This change replaces UnMapAtEnd() with a new function RemapAtEnd()
which combines the unmapping of the tail region and remapping of it to
achieve the following two things:

1) Fixes this double unmap issue by updating the base_size_ member
variable to exclude the already-unmapped tail region so that ~MemMap()
will not unmap the tail region again.

2) Improves on the non-atomicity issue in the unmap/map sequence in
CreateZygoteSpace(). That is, once the unused tail portion of the
memory region of the origina alloc space is unmapped, something like
libc could come along and take that memory region, before the memory
region is mapped again for the new alloc space. This, as a result,
would make a hole between the old alloc (new zygote) space and the new
alloc space and cause the two spaces to be
non-contiguous. RemapAtEnd() eliminates new/malloc allocations between
the unmap and the map calls. But note this still isn't perfect as
other threads could in theory take the memory region between the
munmap and the mmap calls.

Added tests.

Change-Id: I43bc3a33a2cbfc7a092890312e34aa5285384589
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
9004cb6591781d1e6c5ec6d7bc6dc99d9ecee124 27-Jul-2013 Brian Carlstrom <bdc@google.com> Allow MemMap to support empty map requests

Discovered trying to use ZipEntry::ExtractToMemMap on an empty preloaded-classes.

Bug: 8659045
Change-Id: Icfbbe6b313e2d1ee708b44a8d8d354d6203fd669