diff options
author | 2019-12-17 16:28:48 -0800 | |
---|---|---|
committer | 2019-12-18 17:52:47 +0000 | |
commit | 96cbde8221731ac10bf6811ed4c415bbea45656b (patch) | |
tree | 68d52d897e7035770d7d6b01047432e5ae688c69 /openjdkjvmti/alloc_manager.cc | |
parent | 219420ea349960863f35b01353356c10a3736e57 (diff) |
Fix alignment bug in PreObjectAlloc
We were incorrectly setting the byte-count to a potentially unaligned
value. This could cause CHECK failures in rare situations.
Test: ./test.py --host
Bug: 146436130
Change-Id: Ia8d650b085af875fc45e5408ed7b81f9ce69df1f
Diffstat (limited to 'openjdkjvmti/alloc_manager.cc')
-rw-r--r-- | openjdkjvmti/alloc_manager.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/openjdkjvmti/alloc_manager.cc b/openjdkjvmti/alloc_manager.cc index 597ab05ba0..f5e4af60c2 100644 --- a/openjdkjvmti/alloc_manager.cc +++ b/openjdkjvmti/alloc_manager.cc @@ -41,6 +41,7 @@ #include "handle.h" #include "mirror/class-inl.h" #include "runtime.h" +#include "runtime_globals.h" #include "scoped_thread_state_change-inl.h" #include "scoped_thread_state_change.h" #include "thread-current-inl.h" @@ -104,7 +105,9 @@ void JvmtiAllocationListener::PreObjectAllocated(art::Thread* self, return oss.str(); }); if (!type->IsVariableSize()) { - *byte_count = type->GetObjectSize(); + *byte_count = + std::max(art::RoundUp(static_cast<size_t>(type->GetObjectSize()), art::kObjectAlignment), + *byte_count); } } |