summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiakai Zhang <jiakaiz@google.com>2024-05-03 12:19:45 +0100
committerJiakai Zhang <jiakaiz@google.com>2024-05-03 16:16:48 +0000
commit51300eb2b71936ec69ab6737a2270b5019b6b888 (patch)
treed4ea6292331508da49d941bb4b082952f5916509
parent7c26f98bf3d95616d516dd8cdb0ff4ef64e0b219 (diff)
downloadart-51300eb2b71936ec69ab6737a2270b5019b6b888.tar.gz
Add process name suffix for Pre-reboot Dexopt chroot.
Example crash logs: 05-01 09:59:58.374 2675 2675 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 05-01 09:59:58.374 2675 2675 F DEBUG : Build fingerprint: 'generic/aosp_cf_x86_64_phone/vsoc_x86_64:VanillaIceCream/MAIN.9d8f75cf/eng.jiakai.20240430.120128:userdebug/test-keys' 05-01 09:59:58.374 2675 2675 F DEBUG : Revision: '0' 05-01 09:59:58.374 2675 2675 F DEBUG : ABI: 'x86' 05-01 09:59:58.374 2675 2675 F DEBUG : Timestamp: 2024-05-01 09:59:58.161156831+0000 05-01 09:59:58.374 2675 2675 F DEBUG : Process uptime: 2s 05-01 09:59:58.374 2675 2675 F DEBUG : Cmdline: /apex/com.android.art/bin/dex2oat32 (Pre-reboot Dexopt chroot) --zip-fd=14 --zip-location=/system_ext/priv-app/Launcher3QuickStep/Launcher3QuickStep.apk ... 05-01 09:59:58.375 2675 2675 F DEBUG : pid: 2669, tid: 2669, name: dex2oat32 >>> /apex/com.android.art/bin/dex2oat32 (Pre-reboot Dexopt chroot) <<< 05-01 09:59:58.375 2675 2675 F DEBUG : uid: 1082 05-01 09:59:58.375 2675 2675 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- 05-01 09:59:58.375 2675 2675 F DEBUG : Abort message: 'test' ... Bug: 311377497 Test: Trigger a crash and see the logs. Change-Id: I84bf82afa1fe272b4a9f68e863447b11ea4d425d
-rw-r--r--artd/artd.cc32
-rw-r--r--artd/artd.h2
-rw-r--r--build/apex/art.rc7
-rw-r--r--dexopt_chroot_setup/dexopt_chroot_setup.cc26
-rw-r--r--libarttools/art_exec.cc2
5 files changed, 36 insertions, 33 deletions
diff --git a/artd/artd.cc b/artd/artd.cc
index f3853365fc..3eef99d7a8 100644
--- a/artd/artd.cc
+++ b/artd/artd.cc
@@ -606,8 +606,7 @@ ndk::ScopedAStatus Artd::isProfileUsable(const ProfilePath& in_profile,
FdLogger fd_logger;
- CmdlineBuilder art_exec_args;
- art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities");
+ CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder());
CmdlineBuilder args;
args.Add(OR_RETURN_FATAL(GetProfman()));
@@ -659,8 +658,7 @@ ndk::ScopedAStatus Artd::CopyAndRewriteProfileImpl(File src,
FdLogger fd_logger;
- CmdlineBuilder art_exec_args;
- art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities");
+ CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder());
CmdlineBuilder args;
args.Add(OR_RETURN_FATAL(GetProfman())).Add("--copy-and-update-profile-key");
@@ -833,8 +831,7 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil
FdLogger fd_logger;
- CmdlineBuilder art_exec_args;
- art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities");
+ CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder());
CmdlineBuilder args;
args.Add(OR_RETURN_FATAL(GetProfman()));
@@ -1028,8 +1025,7 @@ ndk::ScopedAStatus Artd::dexopt(
FdLogger fd_logger;
- CmdlineBuilder art_exec_args;
- art_exec_args.Add(OR_RETURN_FATAL(GetArtExec())).Add("--drop-capabilities");
+ CmdlineBuilder art_exec_args = OR_RETURN_FATAL(GetArtExecCmdlineBuilder());
CmdlineBuilder args;
args.Add(OR_RETURN_FATAL(GetDex2Oat()));
@@ -1549,7 +1545,13 @@ bool Artd::DenyArtApexDataFilesLocked() {
Result<std::string> Artd::GetProfman() { return BuildArtBinPath("profman"); }
-Result<std::string> Artd::GetArtExec() { return BuildArtBinPath("art_exec"); }
+Result<CmdlineBuilder> Artd::GetArtExecCmdlineBuilder() {
+ CmdlineBuilder args;
+ args.Add(OR_RETURN(BuildArtBinPath("art_exec")))
+ .Add("--drop-capabilities")
+ .AddIf(options_.is_pre_reboot, "--process-name-suffix=Pre-reboot Dexopt chroot");
+ return args;
+}
bool Artd::ShouldUseDex2Oat64() {
return !props_->GetOrEmpty("ro.product.cpu.abilist64").empty() &&
@@ -1782,10 +1784,8 @@ Result<void> Artd::PreRebootInitDeriveClasspath(const std::string& path) {
return ErrnoErrorf("Failed to create '{}'", path);
}
- CmdlineBuilder args;
- args.Add(OR_RETURN(GetArtExec()))
- .Add("--drop-capabilities")
- .Add("--keep-fds=%d", output->Fd())
+ CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder());
+ args.Add("--keep-fds=%d", output->Fd())
.Add("--")
.Add("/apex/com.android.sdkext/bin/derive_classpath")
.Add("/proc/self/fd/%d", output->Fd());
@@ -1811,10 +1811,8 @@ Result<void> Artd::PreRebootInitDeriveClasspath(const std::string& path) {
}
Result<void> Artd::PreRebootInitBootImages() {
- CmdlineBuilder args;
- args.Add(OR_RETURN(GetArtExec()))
- .Add("--drop-capabilities")
- .Add("--")
+ CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder());
+ args.Add("--")
.Add(OR_RETURN(BuildArtBinPath("odrefresh")))
.Add("--only-boot-images")
.Add("--compile");
diff --git a/artd/artd.h b/artd/artd.h
index 07927104df..a926dbc652 100644
--- a/artd/artd.h
+++ b/artd/artd.h
@@ -263,7 +263,7 @@ class Artd : public aidl::com::android::server::art::BnArtd {
android::base::Result<std::string> GetProfman();
- android::base::Result<std::string> GetArtExec();
+ android::base::Result<tools::CmdlineBuilder> GetArtExecCmdlineBuilder();
bool ShouldUseDex2Oat64();
diff --git a/build/apex/art.rc b/build/apex/art.rc
index bab7fe30a3..8a98a5f670 100644
--- a/build/apex/art.rc
+++ b/build/apex/art.rc
@@ -26,7 +26,12 @@ service artd /apex/com.android.art/bin/artd
# Same as above, but for Pre-reboot Dexopt. It runs in a chroot environment that
# is set up by dexopt_chroot_setup. It's a lazy service that is started and
# stopped dynamically as needed.
-service artd_pre_reboot /apex/com.android.art/bin/art_exec --chroot=/mnt/pre_reboot_dexopt/chroot -- /apex/com.android.art/bin/artd --pre-reboot
+service artd_pre_reboot /apex/com.android.art/bin/art_exec \
+ --chroot=/mnt/pre_reboot_dexopt/chroot \
+ --process-name-suffix="Pre-reboot Dexopt chroot" \
+ -- \
+ /apex/com.android.art/bin/artd \
+ --pre-reboot
interface aidl artd_pre_reboot
disabled # Prevents the service from automatically starting at boot.
oneshot # Prevents the service from automatically restarting each time it is stopped.
diff --git a/dexopt_chroot_setup/dexopt_chroot_setup.cc b/dexopt_chroot_setup/dexopt_chroot_setup.cc
index 967cb20c1e..f7d1ea4d37 100644
--- a/dexopt_chroot_setup/dexopt_chroot_setup.cc
+++ b/dexopt_chroot_setup/dexopt_chroot_setup.cc
@@ -97,13 +97,17 @@ Result<void> Run(std::string_view log_name, const std::vector<std::string>& args
return {};
}
-Result<std::string> GetArtExec() {
+Result<CmdlineBuilder> GetArtExecCmdlineBuilder() {
std::string error_msg;
std::string art_root = GetArtRootSafe(&error_msg);
if (!error_msg.empty()) {
return Error() << error_msg;
}
- return art_root + "/bin/art_exec";
+ CmdlineBuilder args;
+ args.Add(art_root + "/bin/art_exec")
+ .Add("--chroot=%s", DexoptChrootSetup::CHROOT_DIR)
+ .Add("--process-name-suffix=Pre-reboot Dexopt chroot");
+ return args;
}
Result<void> CreateDir(const std::string& path) {
@@ -408,19 +412,15 @@ Result<void> DexoptChrootSetup::SetUpChroot(const std::optional<std::string>& ot
PLOG(WARNING) << "Failed to generate empty linker config to suppress warnings";
}
- CmdlineBuilder args;
- args.Add(OR_RETURN(GetArtExec()))
- .Add("--chroot=%s", CHROOT_DIR)
- .Add("--")
+ CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder());
+ args.Add("--")
.Add("/system/bin/apexd")
.Add("--otachroot-bootstrap")
.AddIf(!IsOtaUpdate(ota_slot), "--also-include-staged-apexes");
OR_RETURN(Run("apexd", args.Get()));
- args = CmdlineBuilder();
- args.Add(OR_RETURN(GetArtExec()))
- .Add("--chroot=%s", CHROOT_DIR)
- .Add("--drop-capabilities")
+ args = OR_RETURN(GetArtExecCmdlineBuilder());
+ args.Add("--drop-capabilities")
.Add("--")
.Add("/apex/com.android.runtime/bin/linkerconfig")
.Add("--target")
@@ -432,10 +432,8 @@ Result<void> DexoptChrootSetup::SetUpChroot(const std::optional<std::string>& ot
Result<void> DexoptChrootSetup::TearDownChroot() const {
if (OS::FileExists(PathInChroot("/system/bin/apexd").c_str())) {
- CmdlineBuilder args;
- args.Add(OR_RETURN(GetArtExec()))
- .Add("--chroot=%s", CHROOT_DIR)
- .Add("--")
+ CmdlineBuilder args = OR_RETURN(GetArtExecCmdlineBuilder());
+ args.Add("--")
.Add("/system/bin/apexd")
.Add("--unmount-all")
.Add("--also-include-staged-apexes");
diff --git a/libarttools/art_exec.cc b/libarttools/art_exec.cc
index 704b25dddb..dfd0ca5bf9 100644
--- a/libarttools/art_exec.cc
+++ b/libarttools/art_exec.cc
@@ -67,6 +67,8 @@ Supported options:
--keep-fds=FILE_DESCRIPTORS: A semicolon-separated list of file descriptors to keep open.
--env=KEY=VALUE: Set an environment variable. This flag can be passed multiple times to set
multiple environment variables.
+ --process-name-suffix=SUFFIX: Add a suffix in parentheses to argv[0] when calling `execv`. This
+ suffix will show up as part of the process name in tombstone when the process crashes.
)";
constexpr int kErrorUsage = 100;