runtime: Properly unload partially loaded image spaces
When one of the (non-app) image space successfully loads,
it sets up runtime callee-save methods.
If it is later unloaded, callee-save methods are now pointing to memory
that is no longer valid (viewed as all 0s in the debugger).
Runtime::Init skips creating its own runtime methods if it already sees
that the runtime methods were set to non-null, thus dangling runtime
methods.
This crash would nominally manifest itself in unwinding the first time, or as a DCHECK
failure in the interpreter bridge invocation during aborting if debugging was enabled.
To get into this state:
* Fill up the /data partition (but perhaps leave a little bit of room
for one image, but not all images)
* Reboot the device or run zygote manually.
Test: adb shell dd if=/dev/zero of=/data/local/tmp/tempFiller.deleteMe bs=1024 count=50g ; adb reboot
Bug: 36033084
Change-Id: I728c1058b003fcf5e98dc2746d53e44b688c4605
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index e61ec23..eb068b3 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1963,12 +1963,23 @@
}
}
+void Runtime::ClearInstructionSet() {
+ instruction_set_ = InstructionSet::kNone;
+}
+
void Runtime::SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type) {
DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastCalleeSaveType));
CHECK(method != nullptr);
callee_save_methods_[type] = reinterpret_cast<uintptr_t>(method);
}
+void Runtime::ClearCalleeSaveMethods() {
+ for (size_t i = 0; i < static_cast<size_t>(kLastCalleeSaveType); ++i) {
+ CalleeSaveType type = static_cast<CalleeSaveType>(i);
+ callee_save_methods_[type] = reinterpret_cast<uintptr_t>(nullptr);
+ }
+}
+
void Runtime::RegisterAppInfo(const std::vector<std::string>& code_paths,
const std::string& profile_output_filename) {
if (jit_.get() == nullptr) {