From e0695ebcc59bebaeba70b2006a6fb06d2964b9dc Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Tue, 29 Jun 2021 10:24:47 -0700 Subject: [PATCH] Revert "Extract info on LoadedPackage crash" The issue has not been reproduced since the finalizer synchronization changes were merged, so remove the signal handler and the stopship. Bug: 159041693 Test: boots Change-Id: I43a590c70a397c5c7eabd0a891d008d4cbfe1f76 --- core/jni/android_content_res_ApkAssets.cpp | 65 ---------------------- 1 file changed, 65 deletions(-) diff --git a/core/jni/android_content_res_ApkAssets.cpp b/core/jni/android_content_res_ApkAssets.cpp index 1be84282f6db6..fc12e174b55d2 100644 --- a/core/jni/android_content_res_ApkAssets.cpp +++ b/core/jni/android_content_res_ApkAssets.cpp @@ -377,61 +377,8 @@ static jlong NativeLoadEmpty(JNIEnv* env, jclass /*clazz*/, jint flags, jobject return CreateGuardedApkAssets(std::move(apk_assets)); } -// STOPSHIP (b/159041693): Revert signal handler when reason for issue is found. -static thread_local std::stringstream destroy_info; -static struct sigaction old_handler_action; - -static void DestroyErrorHandler(int sig, siginfo_t* info, void* ucontext) { - if (sig != SIGSEGV) { - return; - } - - LOG(ERROR) << "(b/159041693) - Failed to destroy ApkAssets " << destroy_info.str(); - if (old_handler_action.sa_handler == SIG_DFL) { - // reset the action to default and re-raise the signal. It will kill the process - signal(sig, SIG_DFL); - raise(sig); - return; - } - if (old_handler_action.sa_handler == SIG_IGN) { - // ignoring SIGBUS won't help us much, as we'll get back right here after retrying. - return; - } - if (old_handler_action.sa_flags & SA_SIGINFO) { - old_handler_action.sa_sigaction(sig, info, ucontext); - } else { - old_handler_action.sa_handler(sig); - } -} - static void NativeDestroy(JNIEnv* /*env*/, jclass /*clazz*/, jlong ptr) { - { - auto scoped_apk_assets = ScopedLock(ApkAssetsFromLong(ptr)); - auto apk_assets = scoped_apk_assets->get(); - destroy_info << "{ptr=" << apk_assets; - if (apk_assets != nullptr) { - destroy_info << ", name='" << apk_assets->GetDebugName() << "'" - << ", idmap=" << apk_assets->GetLoadedIdmap() - << ", {arsc=" << apk_assets->GetLoadedArsc(); - if (auto arsc = apk_assets->GetLoadedArsc()) { - destroy_info << ", strings=" << arsc->GetStringPool() - << ", packages=" << &arsc->GetPackages() << " ["; - for (auto& package : arsc->GetPackages()) { - destroy_info << "{unique_ptr=" << &package << ", package=" << package.get() - << "},"; - } - destroy_info << "]"; - } - destroy_info << "}"; - } - destroy_info << "}"; - } - DeleteGuardedApkAssets(ApkAssetsFromLong(ptr)); - - // Deleting the apk assets did not lead to a crash. - destroy_info.str(""); - destroy_info.clear(); } static jstring NativeGetAssetPath(JNIEnv* env, jclass /*clazz*/, jlong ptr) { @@ -591,18 +538,6 @@ int register_android_content_res_ApkAssets(JNIEnv* env) { jclass parcelFd = FindClassOrDie(env, "android/os/ParcelFileDescriptor"); gParcelFileDescriptorOffsets.detachFd = GetMethodIDOrDie(env, parcelFd, "detachFd", "()I"); - - // STOPSHIP (b/159041693): Revert signal handler when reason for issue is found. - sigset_t allowed; - sigemptyset(&allowed); - sigaddset(&allowed, SIGSEGV); - pthread_sigmask(SIG_UNBLOCK, &allowed, nullptr); - struct sigaction action = { - .sa_flags = SA_SIGINFO, - .sa_sigaction = &DestroyErrorHandler, - }; - sigaction(SIGSEGV, &action, &old_handler_action); - return RegisterMethodsOrDie(env, "android/content/res/ApkAssets", gApkAssetsMethods, arraysize(gApkAssetsMethods)); }