From 77c1f592fa90dab4e3d25465d8e833889511a4f4 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Wed, 11 Mar 2020 16:33:12 -0700 Subject: [PATCH] Debug.isVmapStack reads kernel configs only ... but not other runtime VINTF info. This may or may not fix the nullptr exception when accessing getRuntimeInfo(). In either case, this change should improves code health in general: - it avoids reading things it doesn't need - it avoids copying the map Bug: 151092221 Test: m libandroid_runtime -j Change-Id: I6cb9052eb56fd83ef7ee81751d9791533a36aeed --- core/jni/android_os_Debug.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp index 0d0dc3ede7547..f7c6dbd1a65de 100644 --- a/core/jni/android_os_Debug.cpp +++ b/core/jni/android_os_Debug.cpp @@ -853,8 +853,11 @@ static jboolean android_os_Debug_isVmapStack(JNIEnv *env, jobject clazz) } cfg_state = CONFIG_UNKNOWN; if (cfg_state == CONFIG_UNKNOWN) { - const std::map configs = - vintf::VintfObject::GetInstance()->getRuntimeInfo()->kernelConfigs(); + auto runtime_info = vintf::VintfObject::GetInstance() + ->getRuntimeInfo(false /* skip cache */, + vintf::RuntimeInfo::FetchFlag::CONFIG_GZ); + CHECK(runtime_info != nullptr) << "Kernel configs cannot be fetched. b/151092221"; + const std::map& configs = runtime_info->kernelConfigs(); std::map::const_iterator it = configs.find("CONFIG_VMAP_STACK"); cfg_state = (it != configs.end() && it->second == "y") ? CONFIG_SET : CONFIG_UNSET; }