目录
一、lxc-start命令
1.lxc-start: android1: tools/lxc_start.c: main: 192 You lack access to /home/xinyi/code/lxc-4.0.0/out/var/lib/lxc
找到报错源码地方:
lxcpath = my_args.lxcpath[0];
if (access(lxcpath, O_RDONLY) < 0) {
ERROR("You lack access to %s", lxcpath);
exit(err);
}
my_args就是lxc-start命令参数,默认lxcpath是编译时lxc的一个输出目录,而在android上则没有这个目录。
在arguments.h中发现lxcpath可以通过命令行的-P参数传递:
#define LXC_COMMON_OPTIONS \
{ "name", required_argument, 0, 'n' }, \
{ "help", no_argument, 0, 'h' }, \
{ "usage", no_argument, 0, OPT_USAGE }, \
{ "version", no_argument, 0, OPT_VERSION }, \
{ "quiet", no_argument, 0, 'q' }, \
{ "logfile", required_argument, 0, 'o' }, \
{ "logpriority", required_argument, 0, 'l' }, \
{ "lxcpath", required_argument, 0, 'P' }, \
{ "rcfile", required_argument, 0, OPT_RCFILE }, \
{ 0, 0, 0, 0 }
gdbserver64 :1234 lxc-start -P /data/media/build_lxc/containers -n android1 -- /init
,注意-P参数要在启动程序之前指定。
最终解决办法:更好的方式是在编译时给configure指定参数--with-config-path=/data/media/build_lxc/containers
,这样参数就能全局生效。否则使用其它的lxc-xx命令时都得带上P参数,使用不方便。
2.Failed to create lock for android1
找到报错源码位置lxccontainer.c:
c->slock = lxc_newlock(c->config_path, name);
if (!c->slock) {
fprintf(stderr, "Failed to create lock for %s\n", name);
goto err;
}
一直往下跟踪,最终发现报错地方utils.c的get_rundir方法报错:
struct stat sb;
if (stat(RUNTIME_PATH, &sb) < 0)
return NULL;
获取RUNTIME_PATH的文件状态报错,经打印RUNTIME_PATH为/run,没有这个目录自然报错。
RUNTIME_PATH是一个宏,可以在编译时设定:
root@xinyi-virtual-machine:/home/xinyi/code/lxc-4.0.0# ./configure -h | grep runtime
--with-runtime-path=dir runtime directory (default: /run)
最终解决办法:可以在编译时通过--with-runtime-path
参数设置RUNTIME_PATH的值为一个已存在的目录就不会报错
3.各种配置文件解析错误
注意不同版本的lxc程序要使用对应版本的配置文件,配置文件模板位于out/share/lxc/config/
下。
4.lxc-start: android1: lxccontainer.c: wait_on_daemonized_start: 852 Received container state "ABORTING" instead of "RUNNING"
查看日志:
lxc-start android1 20240319182325.872 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319182325.901 WARN initutils - initutils.c:setproctitle:314 - Invalid argument - Failed to set cmdline
lxc-start android1 20240319182325.901 INFO lxccontainer - lxccontainer.c:do_lxcapi_start:970 - Failed to set process title to [lxc monitor] /data/media/build_lxc/containers android1
lxc-start android1 20240319182325.903 INFO start - start.c:lxc_check_inherited:277 - Closed inherited fd 12
lxc-start android1 20240319182325.904 INFO lsm - lsm/lsm.c:lsm_init:29 - LSM security driver nop
lxc-start android1 20240319182325.904 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/dev/memcg rw,relatime shared:4 - cgroup none rw
,memory
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/dev/blkio rw,nosuid,nodev,noexec,relatime share
d:10 - cgroup none rw,blkio
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/dev/cg2_bpf rw,nosuid,nodev,noexec,relatime sha
red:19 - cgroup2 none rw
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2932 - Failed parsing mountpoint from "42 15 0:31 / /dev/cg2_bpf rw,nosuid,nodev,noexec,relatime shared:19 -
cgroup2 none rw
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/dev/cpuctl rw,nosuid,nodev,noexec,relatime shar
ed:20 - cgroup none rw,cpu
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/acct rw,nosuid,nodev,noexec,relatime shared:21
- cgroup none rw,cpuacct
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/dev/cpuset rw,nosuid,nodev,noexec,relatime shar
ed:22 - cgroup none rw,cpuset,noprefix,release_agent=/sbin/cpuset_release_agent
"
lxc-start android1 20240319182325.907 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:655 - Found hierarchy not under /sys/fs/cgroup: "/dev/stune rw,nosuid,nodev,noexec,relatime share
d:23 - cgroup none rw,schedtune
"
lxc-start android1 20240319182325.908 INFO start - start.c:lxc_init:850 - Container "android1" is initialized
lxc-start android1 20240319182325.915 ERROR start - start.c:lxc_spawn:1641 - Invalid argument - Failed to clone a new set of namespaces
lxc-start android1 20240319182325.915 ERROR lxccontainer - lxccontainer.c:wait_on_daemonized_start:852 - Received container state "ABORTING" instead of "RUNNING"
lxc-start android1 20240319182325.915 ERROR lxc_start - tools/lxc_start.c:main:308 - The container failed to start
lxc-start android1 20240319182325.915 ERROR lxc_start - tools/lxc_start.c:main:311 - To get more details, run the container in foreground mode
lxc-start android1 20240319182325.915 ERROR lxc_start - tools/lxc_start.c:main:314 - Additional information can be obtained by setting the --logfile and --logpriority options
lxc-start android1 20240319182325.919 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319182325.921 ERROR start - start.c:__lxc_start:1947 - Failed to spawn container "android1"
lxc-start android1 20240319182325.921 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319182325.921 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319182325.921 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
- 错误1(已解决,挂载cgroup2到/sys/fs/cgroup下。或者不用管,不影响lxc-start命令的执行): Found hierarchy not under /sys/fs/cgroup: "/dev/memcg
查看cgroup的挂载点,android是在/dev目录,而linux一般都是在/sys/fs/cgroup下。kona:/ # mount | grep cgroup none on /dev/memcg type cgroup (rw,relatime,memory) none on /dev/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) none on /dev/cg2_bpf type cgroup2 (rw,nosuid,nodev,noexec,relatime) none on /dev/cpuctl type cgroup (rw,nosuid,nodev,noexec,relatime,cpu) none on /acct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct) none on /dev/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,noprefix,release_agent=/sbin/cpuset_release_agent) none on /dev/stune type cgroup (rw,nosuid,nodev,noexec,relatime,schedtune)
找到源码报错位置cgfsng.c
/* Note, if we change how mountinfo works, then our caller will need to
* verify /sys/fs/cgroup/ in this field.
*/
if (strncmp(p, DEFAULT_CGROUP_MOUNTPOINT "/", 15) != 0)
return log_error(NULL, "Found hierarchy not under " DEFAULT_CGROUP_MOUNTPOINT ": \"%s\"", p);
#define DEFAULT_CGROUP_MOUNTPOINT "/sys/fs/cgroup"
,尝试改变默认的cgroup挂载点#define DEFAULT_CGROUP_MOUNTPOINT "/dev"
。
修改之后仍然报错,但报错不一样
1-1)Failed parsing mountpoint from
:
lxc-start android1 20240320173349.220 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240320173349.246 WARN initutils - initutils.c:setproctitle:314 - Invalid argument - Failed to set cmdline
lxc-start android1 20240320173349.246 INFO lxccontainer - lxccontainer.c:do_lxcapi_start:970 - Failed to set process title to [lxc monitor] /data/media/build_lxc/containers android1
lxc-start android1 20240320173349.250 INFO start - start.c:lxc_check_inherited:277 - Closed inherited fd 12
lxc-start android1 20240320173349.250 INFO start - start.c:lxc_check_inherited:277 - Closed inherited fd 43
lxc-start android1 20240320173349.251 INFO lsm - lsm/lsm.c:lsm_init:29 - LSM security driver nop
lxc-start android1 20240320173349.251 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2933 - Failed parsing mountpoint from "41 15 0:30 / /dev/memcg rw,relatime shared:4 - cgroup none rw,memory
"
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2933 - Failed parsing mountpoint from "22 15 0:21 / /dev/blkio rw,nosuid,nodev,noexec,relatime shared:10 - cgroup non
e rw,blkio
"
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2933 - Failed parsing mountpoint from "42 15 0:31 / /dev/cg2_bpf rw,nosuid,nodev,noexec,relatime shared:19 - cgroup2
none rw
"
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2933 - Failed parsing mountpoint from "43 15 0:32 / /dev/cpuctl rw,nosuid,nodev,noexec,relatime shared:20 - cgroup no
ne rw,cpu
"
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:656 - Found hierarchy not under /dev: "/acct rw,nosuid,nodev,noexec,relatime shared:21 - cgroup none rw,cp
uacct
"
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2933 - Failed parsing mountpoint from "45 15 0:34 / /dev/cpuset rw,nosuid,nodev,noexec,relatime shared:22 - cgroup no
ne rw,cpuset,noprefix,release_agent=/sbin/cpuset_release_agent
"
lxc-start android1 20240320173349.256 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2933 - Failed parsing mountpoint from "46 15 0:35 / /dev/stune rw,nosuid,nodev,noexec,relatime shared:23 - cgroup non
e rw,schedtune
"
lxc-start android1 20240320173349.257 INFO start - start.c:lxc_init:850 - Container "android1" is initialized
lxc-start android1 20240320173349.264 ERROR start - start.c:lxc_spawn:1641 - Invalid argument - Failed to clone a new set of namespaces
lxc-start android1 20240320173349.264 ERROR lxccontainer - lxccontainer.c:wait_on_daemonized_start:852 - Received container state "ABORTING" instead of "RUNNING"
lxc-start android1 20240320173349.264 ERROR lxc_start - tools/lxc_start.c:main:308 - The container failed to start
lxc-start android1 20240320173349.264 ERROR lxc_start - tools/lxc_start.c:main:311 - To get more details, run the container in foreground mode
lxc-start android1 20240320173349.264 ERROR lxc_start - tools/lxc_start.c:main:314 - Additional information can be obtained by setting the --logfile and --logpriority options
lxc-start android1 20240320173349.266 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240320173349.266 ERROR start - start.c:__lxc_start:1947 - Failed to spawn container "android1"
lxc-start android1 20240320173349.272 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240320173349.272 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240320173349.272 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
最终发现与DEFAULT_CGROUP_MOUNTPOINT相关的原来字符串长度15,需要改成5。
1-2)Failed to find current cgroup
lxc-start android1 20240319140556.329 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319140606.814 WARN initutils - initutils.c:setproctitle:314 - Invalid argument - Failed to set cmdline
lxc-start android1 20240319140606.815 INFO lxccontainer - lxccontainer.c:do_lxcapi_start:970 - Failed to set process title to [lxc monitor] /data/media/build_lxc/conta
lxc-start android1 20240319140606.820 INFO lsm - lsm/lsm.c:lsm_init:29 - LSM security driver nop
lxc-start android1 20240319140606.820 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319140606.823 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2945 - Failed to find current cgroup
lxc-start android1 20240319140606.823 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2945 - Failed to find current cgroup
lxc-start android1 20240319140606.823 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_get_controllers:656 - Found hierarchy not under /dev: "/acct rw,nosuid,nodev,noexec,rela
"
lxc-start android1 20240319140606.823 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2945 - Failed to find current cgroup
lxc-start android1 20240319140606.824 INFO start - start.c:lxc_init:850 - Container "android1" is initialized
lxc-start android1 20240319140606.824 WARN cgfsng - cgroups/cgfsng.c:create_cgroup_tree:1154 - File exists - The /dev/cg2_bpf//lxc.monitor.android1 cgroup already exis
lxc-start android1 20240319140606.824 ERROR cgfsng - cgroups/cgfsng.c:cgfsng_monitor_create:1261 - Failed to create cgroup "(null)"
lxc-start android1 20240319140606.825 WARN cgfsng - cgroups/cgfsng.c:create_cgroup_tree:1154 - File exists - The /dev/cg2_bpf//lxc.monitor.android1-1 cgroup already ex
lxc-start android1 20240319140606.825 ERROR cgfsng - cgroups/cgfsng.c:cgfsng_monitor_create:1261 - Failed to create cgroup "(null)"
lxc-start android1 20240319140606.826 WARN cgfsng - cgroups/cgfsng.c:create_cgroup_tree:1154 - File exists - The /dev/cg2_bpf//lxc.monitor.android1-2 cgroup already ex
lxc-start android1 20240319140606.826 ERROR cgfsng - cgroups/cgfsng.c:cgfsng_monitor_create:1261 - Failed to create cgroup "(null)"
lxc-start android1 20240319140606.828 ERROR cgfsng - cgroups/cgfsng.c:cg_legacy_filter_and_set_cpus:353 - No such file or directory - Failed to read file "/dev/cpuset//
lxc-start android1 20240319140606.828 ERROR cgfsng - cgroups/cgfsng.c:cg_legacy_handle_cpuset_hierarchy:546 - No such file or directory - Failed to remove isolated cpus
lxc-start android1 20240319140606.828 ERROR cgfsng - cgroups/cgfsng.c:create_cgroup_tree:1158 - No such file or directory - Failed to handle legacy cpuset controller
lxc-start android1 20240319140606.828 ERROR cgfsng - cgroups/cgfsng.c:cgfsng_monitor_create:1261 - Failed to create cgroup "(null)"
lxc-start android1 20240319140606.829 ERROR cgfsng - cgroups/cgfsng.c:cg_legacy_filter_and_set_cpus:353 - No such file or directory - Failed to read file "/dev/cpuset//
lxc-start android1 20240319140606.830 ERROR cgfsng - cgroups/cgfsng.c:cg_legacy_handle_cpuset_hierarchy:546 - No such file or directory - Failed to remove isolated cpus
lxc-start android1 20240319140606.830 ERROR cgfsng - cgroups/cgfsng.c:create_cgroup_tree:1158 - No such file or directory - Failed to handle legacy cpuset controller
lxc-start android1 20240319140606.830 ERROR cgfsng - cgroups/cgfsng.c:cgfsng_monitor_create:1261 - Failed to create cgroup "(null)"
lxc-start android1 20240319140606.836 ERROR cgfsng - cgroups/cgfsng.c:cg_legacy_filter_and_set_cpus:353 - No such file or directory - Failed to read file "/dev/cpuset//
lxc-start android1 20240319140606.837 ERROR cgfsng - cgroups/cgfsng.c:cg_legacy_handle_cpuset_hierarchy:546 - No such file or directory - Failed to remove isolated cpus
lxc-start android1 20240319140606.837 ERROR cgfsng - cgroups/cgfsng.c:create_cgroup_tree:1158 - No such file or directory - Failed to handle legacy cpuset controller
经调试发现此处并不是直接导致程序崩溃的原因,见cgfsng.c的cg_hybrid_get_current_cgroup方法。根本原因如下:
将/dev/cg2_bpf//lxc.monitor.android1-*
文件全部删除,重新执行报错:
1-3)/dev/cpuset/cpuset.cpus文件不存在
android10中/dev/cpuset/cpuset.cpus文件实际为/dev/cpuset/cpus,由于无法创建链接,只能修改源码将cpuset.cpus修改为cpus.
1-4)/dev/cpuset/cpuset.mems文件不存在
android10中/dev/cpuset/cpuset.mems文件实际为/dev/cpuset/mems,由于无法创建链接,只能修改源码将cpuset.mems修改为mems.
1-5)Failed to spawn container "android1"
xc-start android1 20240319151242.299 ERROR cgfsng - cgroups/cgfsng.c:cg_hybrid_init:2948 - Failed to find current cgroup
lxc-start android1 20240319151242.303 INFO start - start.c:lxc_init:850 - Container "android1" is initialized
lxc-start android1 20240319151242.310 ERROR cgfsng - cgroups/cgfsng.c:mkdir_eexist_on_last:1141 - File exists - Failed to create directory "/dev/cpuset//lxc.m
lxc-start android1 20240319151242.310 INFO cgfsng - cgroups/cgfsng.c:cgfsng_monitor_create:1275 - The monitor process uses "lxc.monitor.android1" as cgroup
lxc-start android1 20240319151242.317 ERROR cgfsng - cgroups/cgfsng.c:mkdir_eexist_on_last:1141 - File exists - Failed to create directory "/dev/cpuset//lxc.p
lxc-start android1 20240319151242.318 INFO cgfsng - cgroups/cgfsng.c:cgfsng_payload_create:1354 - The container process uses "lxc.payload.android1" as cgroup
lxc-start android1 20240319151242.323 ERROR start - start.c:lxc_spawn:1641 - Invalid argument - Failed to clone a new set of namespaces
lxc-start android1 20240319151242.324 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319151242.324 ERROR start - start.c:__lxc_start:1947 - Failed to spawn container "android1"
lxc-start android1 20240319151242.324 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319151242.324 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319151242.330 WARN utils - utils.c:recursive_destroy:1789 - Device or resource busy - Failed to delete "/dev/blkio//lxc.monitor.andro
lxc-start android1 20240319151242.330 WARN cgfsng - cgroups/cgfsng.c:cgfsng_monitor_destroy:1115 - Failed to destroy "/dev/blkio//lxc.monitor.android1"
lxc-start android1 20240319151242.330 WARN utils - utils.c:recursive_destroy:1789 - Device or resource busy - Failed to delete "/dev/cg2_bpf//lxc.monitor.and
lxc-start android1 20240319151242.330 WARN cgfsng - cgroups/cgfsng.c:cgfsng_monitor_destroy:1115 - Failed to destroy "/dev/cg2_bpf//lxc.monitor.android1"
lxc-start android1 20240319151242.330 WARN cgfsng - cgroups/cgfsng.c:cgfsng_monitor_destroy:1108 - No space left on device - Failed to move monitor 24842 to
lxc-start android1 20240319151242.330 INFO utils - utils.c:get_rundir:247 - RUNTIME_PATH:/data/media/run
lxc-start android1 20240319151243.469 ERROR lxccontainer - lxccontainer.c:wait_on_daemonized_start:852 - Received container state "ABORTING" instead of "RUNNI
lxc-start android1 20240319151243.470 ERROR lxc_start - tools/lxc_start.c:main:308 - The container failed to start
lxc-start android1 20240319151243.470 ERROR lxc_start - tools/lxc_start.c:main:311 - To get more details, run the container in foreground mode
lxc-start android1 20240319151243.471 ERROR lxc_start - tools/lxc_start.c:main:314 - Additional information can be obtained by setting the --logfile and --log
start.c:lxc_spawn:1641 - Invalid argument - Failed to clone a new set of namespaces
导致start - start.c:__lxc_start:1947 - Failed to spawn container "android1"
其实上面的问题,最终可以通过挂载cgroup2解决,mount -t cgroup2 none /sys/fs/cgroup
-
错误2(待解决):Failed to setup console
lxc-start android1 20240319110832.725 ERROR utils - utils.c:safe_mount:1148 - No such file or directory - Failed to mount "/dev/pts/2" onto "/dev/lxc/console" lxc-start android1 20240319110832.725 ERROR conf - conf.c:lxc_setup_ttydir_console:1677 - No such file or directory - Failed to mount "/dev/pts/2" on "/dev/lxc/console" lxc-start android1 20240319110832.725 ERROR conf - conf.c:lxc_setup:3389 - Failed to setup console lxc-start android1 20240319110832.725 ERROR start - start.c:do_start:1235 - Failed to setup container "android1"
-
错误3:Failed to drop capabilities
lxc-start android1 20240319115615.758 ERROR conf - conf.c:setup_caps:2325 - unknown capability mac_admin lxc-start android1 20240319115615.758 ERROR conf - conf.c:lxc_setup:3437 - Failed to drop capabilities lxc-start android1 20240319115615.759 ERROR start - start.c:do_start:1235 - Failed to setup container "android1"
去掉config文件中的lxc.cap.drop配置项
-
错误4:Failed to setup legacy device
lxc-start android1 20240319115933.716 ERROR cgfsng - cgroups/cgfsng.c:cgfsng_setup_limits_legacy:2567 - No such file or directory - Failed to set "devices.deny" lxc-start android1 20240319115933.716 ERROR start - start.c:lxc_spawn:1793 - Failed to setup legacy device cgroup controller limits
5.lxc-start android1 20240319114811.740 ERROR start - start.c:lxc_spawn:1652 - Invalid argument - Failed to clone a new set of namespaces
根据lxc-checkconfig结果,把内核IPC相关参数加上重新编译boot即可。
6.lxc-start android1 20240319113234.817 DEBUG start - start.c:signal_handler:412 - Container init process 7079 exited
情况1:没有配置rootfs。
7.lxc-start/lxc-attach android1 20240319130808.624 ERROR utils - utils.c:mkdir_p:234 - Read-only file system - Failed to create directory "//.cache/"
set | grep HOME
根据源码查看HOME环境变量,发现变成了/,使用export HOME=/data/media/run
改写到读写的目录即可。
8.init程序重启
内核打印的init重启日志:
[10625.400347] init: init first stage started!
[10625.401620] init: [libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[10625.401634] init: [libfs_mgr]ReadFstabFromDt(): failed to read fstab from dt
[10625.401796] init: [libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[10625.403505] init: Using Android DT directory /proc/device-tree/firmware/android/
[10625.735302] init: DM_DEV_CREATE failed for [system_a]: Device or resource busy
[10625.735315] init: [libfs_mgr]Could not create logical partition: system_a
[10625.735364] init: Failed to mount required partitions early ...
[10625.756888] init: #00 pc 00000000000f08f4 /init
[10625.756895] init: #01 pc 000000000006d1b0 /init
[10625.773960] init: 5 output lines suppressed due to ratelimiting
[10625.802222] init: Received control message 'interface_start' for 'android.hardware.secure_element@1.0::ISecureElement/SIM1' from pid: 575 (/system/bin/hwservicemanager)
[10625.802291] init: Could not find 'android.hardware.secure_element@1.0::ISecureElement/SIM1' for ctl.interface_start
[10625.902027] eth0: renamed from mcFcdWPe
[10625.914624] EXT4-fs (dm-0): errors=remount-ro for active namespaces on umount 2
[10625.947666] init: init first stage started!
[10625.949818] init: [libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[10625.949832] init: [libfs_mgr]ReadFstabFromDt(): failed to read fstab from dt
[10625.949996] init: [libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[10625.952250] init: Using Android DT directory /proc/device-tree/firmware/android/
[10626.250183] init: DM_DEV_CREATE failed for [system_a]: Device or resource busy
[10626.250197] init: [libfs_mgr]Could not create logical partition: system_a
[10626.250242] init: Failed to mount required partitions early ...
[10626.274495] init: #00 pc 00000000000f08f4 /init
[10626.274502] init: #01 pc 000000000006d1b0 /init
[10626.293637] init: 5 output lines suppressed due to ratelimiting
[10626.416827] eth0: renamed from mcROpEli
[10626.459337] EXT4-fs (dm-0): errors=remount-ro for active namespaces on umount 2
[10626.472606] audit: audit_lost=1060108 audit_rate_limit=5 audit_backlog_limit=64
[10626.472610] audit: rate limit exceeded
[10626.508642] init: init first stage started!
首先根据https://blog.csdn.net/dp__mcu/article/details/105166856,解决内核日志输出限制:
static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
{
...
/* Ratelimit when not explicitly enabled. */
if (!(devkmsg_log & DEVKMSG_LOG_MASK_ON)) {
if (!___ratelimit(&user->rs, current->comm)){
//return ret;
}
}
...
}
8-1)错误1:
[ 199.010630] my_init: No precompiled sepolicy: No such file or directory
[ 199.010635] my_init: Compiling SELinux policy
[ 199.010782] my_init: Failed to read /vendor/etc/selinux/plat_sepolicy_vers.txt: No such file or directory
[ 199.010800] my_init: Unable to load SELinux policy
容器config文件中配置lxc.mount.entry = /vendor vendor none ro,bind 0 0
,并且要在容器的根文件系统的根目录创建vendor文件夹。
8-2)错误2:
[ 773.052997] my_init: execv("/system/bin/init") failed: No such file or directory
/system/bin/init
即为second阶段的init,所以需要把宿主系统的system目录挂载到容器根文件系统。
容器config文件中配置lxc.mount.entry = /system system none rw,bind 0 0
,并且要在容器的根文件系统的根目录创建system文件夹。而且system/lib下有so库,如果把lxc-start替换为second阶段的init(为动态链接,first阶段的init为静态链接),则需要挂载system,否则找不到init。
8-3)错误3:
[ 1978.764033] init: Couldn't load property file '/odm/etc/build.prop': open() failed: No such file or directory: No such file or directory
[ 1978.764045] init: Couldn't load property file '/product/build.prop': open() failed: No such file or directory: No such file or directory
[ 1978.764057] init: Couldn't load property file '/product_services/build.prop': open() failed: No such file or directory: No such file or directory
[ 1978.764069] init: Couldn't load property file '/factory/factory.prop': open() failed: No such file or directory: No such file or directory
此错误不会导致程序中断,但是不确定这些属性文件是否会影响到后续流程,先把/odm 、/product目录挂载上。/product_services与/factory目录,宿主机也没有,就不管了。
8-4)错误4:
[ 3859.138793] init: Parsing file /init.rc...
[ 3859.139444] init: Unable to read config file '/init.rc': open() failed: No such file or directory
将宿主目录下的所有的.rc文件全部拷贝到容器根文件系统中
此错误又会导致其它的错误
- 1)my_init: Timed out waiting for /dev/.coldboot_done
[ 746.681223] my_init: wait for '/dev/.coldboot_done' timed out and took 60005ms [ 746.681347] my_init: Timed out waiting for /dev/.coldboot_done [ 746.704666] my_init: #00 pc 000000000006c3ac /my_init (android::init::InitFatalReboot()+80) [ 746.704710] my_init: #01 pc 0000000000099998 /my_init (android::init::InitAborter(char const*)+44) [ 746.704743] my_init: #02 pc 000000000000b458 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+580) [ 746.704776] my_init: #03 pc 00000000000510ac /my_init (android::init::wait_for_coldboot_done_action(android::init::BuiltinArguments const&)+464) [ 746.704810] my_init: #04 pc 000000000003c490 /my_init (_ZN7android4init18RunBuiltinFunctionERKNSt3__18functionIFNS0_6ResultINS1_9monostateEEERKNS0_16BuiltinArgumentsEEEERKNS1_6vectorINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENSH_ISJ_EEEERKSJ_+252) [ 746.704841] my_init: #05 pc 000000000003c6fc /my_init (android::init::Command::InvokeFunc(android::init::Subcontext*) const+96) [ 746.704873] my_init: #06 pc 000000000003da34 /my_init (android::init::Action::ExecuteCommand(android::init::Command const&) const+68) [ 746.704904] my_init: #07 pc 000000000003d93c /my_init (android::init::Action::ExecuteOneCommand(unsigned long) const+316) [ 746.704934] my_init: #08 pc 000000000003a6f8 /my_init (android::init::ActionManager::ExecuteOneCommand()+564) [ 746.704964] my_init: #09 pc 0000000000050328 /my_init (android::init::SecondStageMain(int, char**)+8872) [ 746.704993] my_init: #10 pc 0000000000024188 /my_init (main+300) [ 746.705023] my_init: #11 pc 000000000007e898 /system/lib64/bootstrap/libc.so (__libc_init+108) [ 746.705049] my_init: Reboot ending, jumping to kernel
原因:由于没有init.rc,就不会启动ueventd服务(负责冷启动),那么wait_for_coldboot_done最终最终超时,会导致容器init程序重启。
// Queue an action that waits for coldboot done so we know ueventd has set up all of /dev...
am.QueueBuiltinAction(wait_for_coldboot_done_action, "wait_for_coldboot_done");
...
static Result<Success> wait_for_coldboot_done_action(const BuiltinArguments& args) {
Timer t;
std::chrono::nanoseconds timeout = 60s;
#ifdef SLOW_BOARD
timeout = 6000s;
#endif
LOG(VERBOSE) << "Waiting for " COLDBOOT_DONE "...";
// Historically we had a 1s timeout here because we weren't otherwise
// tracking boot time, and many OEMs made their sepolicy regular
// expressions too expensive (http://b/19899875).
// Now we're tracking boot time, just log the time taken to a system
// property. We still panic if it takes more than a minute though,
// because any build that slow isn't likely to boot at all, and we'd
// rather any test lab devices fail back to the bootloader.
if (wait_for_file(COLDBOOT_DONE, timeout) < 0) {
LOG(FATAL) << "Timed out waiting for " COLDBOOT_DONE;
}
property_set("ro.boottime.init.cold_boot_wait", std::to_string(t.duration().count()));
return Success();
}
8-5)错误5:
[ 7155.092725] init: Service 'zygote' (pid 20070) received signal 9
[ 7155.092799] init: Sending signal 9 to service 'zygote' (pid 20070) process group...
[ 7155.093468] libprocessgroup: Successfully killed process cgroup uid 0 pid 20070 in 0ms
zygote开始的服务会莫明地挂掉
8-6)错误6:
把相关的目录挂载即可。
8-7)错误7:
nsenter -m进入命名空间,无法直接引用/system/bin下的指令。报/proc/self/exe不存在和no such file
解决办法:
1)报/proc/self/exe不存在:通过nsenter -t pid -m busybox sh
进入命名空间后,先busybox umount /proc
,然后busybox mount -t proc proc /proc
重新挂载proc文件系统即可。
2)no such file:主要是链接器没有加载,也就是/apex目录下为空。保证apexd服务执行就没有问题。
8-8)错误8:my_init: open() failed for /dev/cgroup_info/cgroup.rc: No such file or directory
云机默认是没有/dev/cgroup_info/cgroup.rc文件及/dev/cgroup_info目录的,需要绑定挂载。否则会有一系列报错:
[ 2471.603218] libprocessgroup: CgroupMap::LoadRcFile called for [1] failed
[ 2471.603224] libprocessgroup: CgroupMap::FindController called for [1] failed, RC file was not initialized properly
[ 2476.293192] my_init: starting service 'exec 4 (/system/bin/recovery-refresh)'...
[ 2476.294616] libprocessgroup: CgroupMap::FindController called for [1] failed, RC file was not initialized properly
[ 2476.294660] libprocessgroup: Failed to make and chown /uid_1000: Read-only file system
8-8X1)错误8-1:my_init: Could not read properties from '/vendor/etc/selinux/vendor_property_contexts': No such file or directory
8-9)错误9:my_init: vdc returned error code: 25
[ 1212.484862] my_init: Calling: /system/bin/vdc cryptfs mountFstab /dev/block/bootdevice/by-name/userdata /data
[ 1212.586191] my_init: vdc returned error code: 25
//这里就是系统进入恢复的原因
[ 1212.586221] my_init: [libfs_mgr]Failure while mounting metadata, setting flag to needing recovery partition on /dev/block/bootdevice/by-name/userdata at /data options: discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier: Invalid argument
[ 1212.599213] my_init: fs_mgr_mount_all suggested recovery, so wiping data via recovery with prompt.: Try again
[ 1212.599227] my_init: Rebooting into recovery
[ 1212.599606] my_init: [libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[ 1212.601878] my_init: Received sys.powerctl='reboot,recovery' from pid: 1 (/my_init)
[ 1212.601910] my_init: Command 'mount_all /vendor/etc/fstab.qcom --late' action=late-fs (/vendor/etc/init/hw/init.target.rc:70) took 155ms and succeeded
[ 1212.601951] my_init: Service 'surfaceflinger' (pid 34) received signal 6
[ 1212.601959] my_init: Sending signal 9 to service 'surfaceflinger' (pid 34) process group...
[ 1212.602092] libprocessgroup: Successfully killed process cgroup uid 1000 pid 34 in 0ms
[ 1212.602846] my_init: Clear action queue and start shutdown trigger
[ 1212.603041] my_init: processing action (shutdown_done) from (<Builtin Action>:0)
[ 1212.603050] my_init: Reboot start, reason: reboot,recovery, rebootTarget: recovery
[ 1212.613163] my_init: Shutdown timeout: 6000 ms
[ 1212.613204] my_init: Could not start shutdown critical service 'chre': Cannot find '/vendor/bin/chre': No such file or directory
//注意这里会杀死服务,所以原本已经启动的服务会莫明的收到signal 9等信号
[ 1212.625054] my_init: terminating init services
[ 1212.665287] apexd: Marking APEXd as starting
[ 1215.661108] my_init: sync() before umount...
[ 1215.692722] my_init: sync() before umount took31ms
[ 1215.693677] my_init: Unmounting /data/media
...
[ 1215.697673] my_init: Unmounting /dev/block
[ 1215.703513] my_init: sync() after umount...
[ 1215.704232] my_init: sync() after umount took0ms
[ 1215.804487] my_init: powerctl_shutdown_time_ms:3201:0
[ 1215.804520] my_init: Reboot ending, jumping to kernel
- 1)为了避免设备反复重启进入恢复模式,修改一下reboot.cpp源码:
更准确的方法位于builtins.cpp,不往bootloader写recovery标记且不改变"sys.powerctl"属性。
static Result<Success> reboot_into_recovery(const std::vector<std::string>& options) {
LOG(ERROR) << "Rebooting into recovery";
//CZ
LOG(ERROR) << "CZLog give up write_bootloader_message";
return Success();
//
// std::string err;
// if (!write_bootloader_message(options, &err)) {
// return Error() << "Failed to set bootloader message: " << err;
// }
// property_set("sys.powerctl", "reboot,recovery");
// return Success();
}
- 2)手动执行
/system/bin/vdc cryptfs mountFstab /dev/block/bootdevice/by-name/userdata /data
,查找失败原因。kona:/ # /system/bin/vdc cryptfs mountFstab /dev/block/bootdevice/by-name/userdata /data vdc V 03-19 11:20:52 18888 18888 vdc.cpp:50] Waited 0ms for vold vdc E 03-19 11:20:53 18888 18888 vdc.cpp:60] Failed: Status(-8, EX_SERVICE_SPECIFIC): '0: '
android::sp<android::IBinder> binder = getServiceAggressive();
if (!binder) {
LOG(ERROR) << "Failed to obtain vold Binder";
exit(EINVAL);
}
auto vold = android::interface_cast<android::os::IVold>(binder);
...
else if (args[0] == "cryptfs" && args[1] == "mountFstab" && args.size() == 4) {
checkStatus(vold->mountFstab(args[2], args[3]));
}
反推源码:
fs_mgr.cpp
→call_vdc
→→fs_mgr_mount_all
if (!call_vdc({"cryptfs", "mountFstab", attempted_entry.blk_device,
attempted_entry.mount_point})) {
PERROR << android::base::StringPrintf(
"Failure while mounting metadata, setting flag to needing recovery "
"partition on %s at %s options: %s",
attempted_entry.blk_device.c_str(), attempted_entry.mount_point.c_str(),
attempted_entry.fs_options.c_str());
encryptable = FS_MGR_MNTALL_DEV_NEEDS_RECOVERY_WIPE_PROMPT;
} else {
encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
}
builtins.cpp
→→→mount_fstab
→→→→do_mount_all
{"mount_all", {1, kMax, {false, do_mount_all}}},
queue_fs_event会监听mount的结果:
else if (code == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY_WIPE_PROMPT) {
/* Setup a wipe via recovery with prompt, and reboot into recovery if chosen */
PLOG(ERROR) << "fs_mgr_mount_all suggested recovery, so wiping data via recovery "
"with prompt.";
const std::vector<std::string> options = {"--prompt_and_wipe_data",
"--reason=fs_mgr_mount_all" };
return reboot_into_recovery(options);
/* If reboot worked, there is no return. */
}
reboot_into_recovery方法改变sys.powerctl属性,从而触发重启方法。
static Result<Success> reboot_into_recovery(const std::vector<std::string>& options) {
LOG(ERROR) << "Rebooting into recovery";
std::string err;
if (!write_bootloader_message(options, &err)) {
return Error() << "Failed to set bootloader message: " << err;
}
property_set("sys.powerctl", "reboot,recovery");
return Success();
}
mount_all应该是某个rc文件触发的,查找find -type f -name "*.rc" 2>/dev/null | xargs grep -nr "mount_all"
且日志里已经有打印,为
[ 130.239570] my_init: processing action (late-fs) from (/vendor/etc/init/hw/init.target.rc:67)
即:mount_all /vendor/etc/fstab.qcom --late
原因分析:
由以上源码分析可知,根本原因是vdc.cpp中的vold->mountFstab执行失败,那么为什么执行失败。
注意这里的vold其实是vold服务,通过binder跨进程调用,此时容器的log服务已经可用,logcat | grep vold查看日志:
03-20 08:42:50.966 29 29 I vold : Vold 3.0 (the awakening) firing up
...
03-20 08:42:50.973 29 29 D vold : VoldNativeService::start() completed OK
03-20 08:42:51.673 29 29 D vold : fscrypt_mount_metadata_encrypted: /data 0
...
//
03-20 08:42:51.733 29 29 E vold : Cannot create dm-crypt device userdata: Device or resource busy
...
→mountFstab(VoldNativeService.cpp)
→→fscrypt_mount_metadata_encrypted(MetadataCrypt.cpp)
→→→create_crypto_blk_dev(MetadataCrypt.cpp)
if (!io || ioctl(dm_fd.get(), DM_DEV_CREATE, io) != 0) {
PLOG(ERROR) << "Cannot create dm-crypt device " << dm_name;
return false;
}
通过dmctl list devices查看,userdata虚拟分区设备确实存在。
解决办法(验证不过):
编辑容器的/vendor/etc/fstab.qcom文件,将/userdata挂载项注释掉。
但是/vendor/etc/fstab.qcom是从宿主机挂载过去的,不能直接修改。要将宿主机的vendor目录copy一份,然后修改/vendor/etc/fstab.qcom,再挂载vendor到容器。但是注释掉之后宿主机会直接挂掉。
8-10)错误10:Error changing dalvik-cache ownership : Read-only file system
[ 3630.758512] DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
[ 3630.758597] DEBUG: Build fingerprint: 'qti/kona/kona:10/QKQ1.210702.001/eng.root.20240319.164253:userdebug/test-keys'
[ 3630.758631] DEBUG: Revision: '0'
[ 3630.758665] DEBUG: ABI: 'arm64'
[ 3630.758759] DEBUG: Timestamp: 2024-03-19 11:44:03+0000
[ 3630.758795] DEBUG: pid: 36, tid: 36, name: app_process64 >>> /system/bin/app_process64 <<<
[ 3630.758828] DEBUG: uid: 0
[ 3630.758868] DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
[ 3630.758914] DEBUG: Abort message: 'Error changing dalvik-cache ownership : Read-only file system,the dalvikCacheDir is:/data/dalvik-cache/arm64'
挂载/data分区时,要以rw模式挂载。
8-11)错误11:has incorrect label or no domain transition from u:r:init:s0 to another SELinux domain defined. Have you configured your service correctly?
很多服务起不来,都是此原因。
解决方法1:把各个相关的rc文件的service都配上属性seclabel u:r:init:s0
,一般都在vendor/etc/init目录下
解决方法2:修改源码 service.cpp->ComputeContextFromExecutable方法,将报错中断地方注释
// if (rc == 0 && computed_context == mycon.get()) {
// return Error() << "File " << service_path << "(labeled \"" << filecon.get()
// << "\") has incorrect label or no domain transition from " << mycon.get()
// << " to another SELinux domain defined. Have you configured your "
// "service correctly? https://source.android.com/security/selinux/"
// "device-policy#label_new_services_and_address_denials";
// }
// if (rc < 0) {
// return Error() << "Could not get process context";
// }
8-12)错误12:surfaceflinger 无法启动
[ 961.019807] DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
[ 961.019892] DEBUG: Build fingerprint: 'qti/kona/kona:10/QKQ1.210702.001/eng.root.20240319.164253:userdebug/test-keys'
[ 961.019924] DEBUG: Revision: '0'
[ 961.019956] DEBUG: ABI: 'arm64'
[ 961.020038] DEBUG: Timestamp: 2024-03-19 11:25:55+0000
[ 961.020071] DEBUG: pid: 37, tid: 37, name: surfaceflinger >>> /system/bin/surfaceflinger <<<
[ 961.020101] DEBUG: uid: 1000
[ 961.020137] DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
[ 961.020180] DEBUG: Abort message: 'failed to create composer client'
[ 961.020214] DEBUG: x0 0000000000000000 x1 0000000000000025 x2 0000000000000006 x3 0000007fe82a5260
[ 961.020245] DEBUG: x4 fefefefeff716472 x5 fefefefeff716472 x6 fefefefeff716472 x7 7f7f7f7f7f7f7f7f
[ 961.020396] DEBUG: x8 00000000000000f0 x9 f3b2425c9720c94b x10 0000000000000001 x11 0000000000000000
[ 961.020437] DEBUG: x12 fffffff0ffffffdf x13 ffffffffffffffff x14 0000000000000004 x15 ffffffffffffffff
[ 961.020468] DEBUG: x16 00000077ae3578c0 x17 00000077ae333910 x18 00000077af4e2000 x19 0000000000000025
[ 961.020497] DEBUG: x20 0000000000000025 x21 00000000ffffffff x22 0000007721703040 x23 00000077af30d020
[ 961.020531] DEBUG: x24 00000077af0229a0 x25 00000077af022888 x26 0000000000000000 x27 00000077af30d020
[ 961.020563] DEBUG: x28 0000000000000000 x29 0000007fe82a5300
[ 961.020592] DEBUG: sp 0000007fe82a5240 lr 00000077ae2e50c4 pc 00000077ae2e50f0
[ 961.034122] DEBUG:
[ 961.034130] DEBUG: backtrace:
[ 961.034200] DEBUG: #00 pc 00000000000830f0 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 21847aa9757f000b0461310a9f5e6e51)
[ 961.034246] DEBUG: #01 pc 0000000000008a14 /system/lib64/liblog.so (__android_log_assert+328) (BuildId: b0a676d291f62cc3b051ab65d26fb52d)
[ 961.034310] DEBUG: #02 pc 000000000008e3cc /system/lib64/libsurfaceflinger.so (android::Hwc2::impl::Composer::Composer(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)+1200) (BuildId: ea8a2fe4e18a254ebd1c61d6103cceea)
[ 961.034347] DEBUG: #03 pc 000000000011ade8 /system/lib64/libsurfaceflinger.so (_ZZN7android14surfaceflinger20createSurfaceFlingerEvEN7Factory16createHWComposerERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE$f8e1ddd5c1a01af33e02be699775c0a6+56) (BuildId: ea8a2fe4e18a254ebd1c61d6103cceea)
[ 961.034386] DEBUG: #04 pc 00000000000d7414 /system/lib64/libsurfaceflinger.so (android::SurfaceFlinger::init()+1336) (BuildId: ea8a2fe4e18a254ebd1c61d6103cceea)
[ 961.034422] DEBUG: #05 pc 00000000000031ac /system/bin/surfaceflinger (main+348) (BuildId: 55a0666e7d0c7d2cf199cfa2af8096c1)
[ 961.034455] DEBUG: #06 pc 000000000007e898 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: 21847aa9757f000b0461310a9f5e6e51)
根据Abort message: 'failed to create composer client'
追踪源码
8-13)cannot execve('/system/bin/logd'): Permission denied
system要以rw挂载
9.服务多次重启导致宿主机重启
一些加了shutdown critical
标记的服务,如果多次重启,就会导致整个系统重启。
9-1)servicemanager服务无法启动
通过在容器中执行strace -o trace.log servicemanager
,查看日志发现:
writev(4, [{iov_base="\0;\16\323\223\371e3\345\366/", iov_len=11}, {iov_base="\6", iov_len=1}, {iov_base="ServiceManager\0", iov_len=15}, {iov_base="cannot become context manager (D"..., iov_len=57}], 4) = 84
对应源码为:
if (binder_become_context_manager(bs)) {
ALOGE("cannot become context manager (%s)\n", strerror(errno));
return -1;
}
int binder_become_context_manager(struct binder_state *bs)
{
struct flat_binder_object obj;
memset(&obj, 0, sizeof(obj));
obj.flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX;
int result = ioctl(bs->fd, BINDER_SET_CONTEXT_MGR_EXT, &obj);
// fallback to original method
if (result != 0) {
android_errorWriteLog(0x534e4554, "121035042");
result = ioctl(bs->fd, BINDER_SET_CONTEXT_MGR, 0);
}
return result;
}
-
servicemanager重启要使很多其它的服务重启,这些服务可以先不用管。
1 service servicemanager /system/bin/servicemanager 2 class core animation 3 user system 4 group system readproc 5 critical 6 onrestart restart healthd 7 onrestart restart zygote 8 onrestart restart audioserver 9 onrestart restart media 10 onrestart restart surfaceflinger 11 onrestart restart inputflinger 12 onrestart restart drm 13 onrestart restart cameraserver 14 onrestart restart keystore 15 onrestart restart gatekeeperd 16 onrestart restart thermalservice 17 writepid /dev/cpuset/system-background/tasks 18 shutdown critical
-
vndservicemanager也会报类似错误
[ 1126.183989] my_init: starting service 'vndservicemanager'... [ 1126.232480] binder: BINDER_SET_CONTEXT_MGR already set [ 1126.237925] binder: 21614:21614 ioctl 4018620d 7fc6833590 returned -16 [ 1126.240509] binder: BINDER_SET_CONTEXT_MGR already set
只是vndservicemanager服务的binder驱动是/dev/vndbinder
查找原因
发现很多服务都会报binder: BINDER_SET_CONTEXT_MGR already set
临时解决办法:
将报错地方 return -1;
注释,确实service_manager服务可以成功起起来。
永久解决办法:
1)方法1:创建新的binder
1.修改内核binder配置,增加一个binder设备,名为binder_pad
2.修改service_manager源码,或者在rc文件中为servicemanager服务指定binder设备为/dev/binder_pad。
建议不直接修改源码,但是通过rc文件指定。
10.核心板秒重启,无法抓取日志怎么办?
在执行启动容器命令之前,先执行下面命令,即使核心板秒重启也能事先抓取到日志。
adb -s ? shell cat /dev/kmsg >klog
10-1) crash1
//drivers/usb/gadget/function/f_fs.c->ffs_data_new(1831行)
6,9531,276678958,-;ffs_data_new(): adb Already mounted
//system/core/bootstat/bootstat.c->addKernelPanicSubReason(682行)
1,9532,276678969,-;Unable to handle kernel NULL pointer dereference at virtual address 0000000000000300
排查思路:adb设备的挂载源码位置,不挂载adb设备。
解决办法:注释容器里adb设备的挂载
见http://xinyiworld.top/wordpress_it/?p=13878
再次思考:容器里一开始已经挂载的adb设备是怎么挂载上的
kona:/ # mount | grep adb
adb on /old-root/dev/usb-ffs/adb type functionfs (rw,relatime)
可以知道,容器的这个adb是在制作容器根文件系统时,存在于宿主根文件系统的备份里。
尝试
umount /old-root/dev/usb-ffs/adb
mount -t functionfs adb /dev/usb-ffs/adb
仍然会报相同错误ffs_data_new(): adb Already mounted
10-2) crash2
7,9886,239165556,-;cnss: Processing driver event: RECOVERY(9), state: 0xe08
7,9887,239165560,-;cnss: Driver recovery is triggered with reason: UNKNOWN(-333167636)
3,9888,239165564,-;cnss: Recovery is already in progress
3,9889,239165567,-;cnss: ASSERT at line 1134
6,9890,239165581,-;------------[ cut here ]------------
2,9891,239165584,-;kernel BUG at /home/xinyi/code/sg865/sg865w_android10/kernel/msm-4.19/drivers/net/wireless/cnss2/main.c:1134!
0,9892,239165587,-;Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
-
cnss是什么
网络相关的一个驱动
drivers/net/wireless/KConfig
source "drivers/net/wireless/cnss2/Kconfig" source "drivers/net/wireless/cnss_utils/Kconfig" source "drivers/net/wireless/cnss_genl/Kconfig"
-
尝试对比android12
发现android12没有CNSS相关的配置选项,把android10所有CNSS的配置项去掉重新编辑内核。
11.zygote服务重启
kona:/data # /system/bin/app_process64 -Xzygote /system/bin --zygote --start-system-server --socket-name=zygote
Exception in thread "main" java.lang.AssertionError: Unable to configure default providers
at sun.security.jca.Providers.<clinit>(Providers.java:74)
at java.security.Security.getProvider(Security.java:401)
at com.android.org.bouncycastle.crypto.digests.AndroidDigestFactory.<clinit>(AndroidDigestFactory.java:36)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:316)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:141)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:882)
zygote之前很多服务没有起起来,先解决前面的问题。
- zygote重启会导致一些服务重启,这些服务可以先忽略。
service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-system-server --socket-name=zygote class main priority -20 user root group root readproc reserved_disk socket zygote stream 660 root system socket usap_pool_primary stream 660 root system onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on onrestart restart audioserver onrestart restart cameraserver onrestart restart media onrestart restart netd onrestart restart wificond onrestart restart vendor.servicetracker-1-1 writepid /dev/cpuset/foreground/tasks
查找原因:
查看logcat日志:
03-19 12:08:39.703 948 948 F zygote64: jni_internal.cc:814] JNI FatalError called: (system_server) Not whitelisted : /proc/31842/status
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] Runtime aborting...
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] Dumping all threads without mutator lock held
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] All threads:
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] DALVIK THREADS (1):
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] "main" prio=5 tid=1 Runnable
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] | group="" sCount=0 dsCount=0 flags=0 obj=0x7242ce78 self=0x7b1942cc00
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] | sysTid=948 nice=0 cgrp=default sched=0/0 handle=0x7b1a994ed0
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] | state=R schedstat=( 685090310 23279113 34 ) utm=30 stm=38 core=1 HZ=100
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] | stack=0x7fdf774000-0x7fdf776000 stackSize=8192KB
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] | held mutexes= "abort lock" "mutator lock"(shared held)
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] native: #00 pc 000000000040fca8 /apex/com.android.runtime/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140)
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] native: #01 pc 00000000004f7510 /apex/com.android.runtime/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+512)
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] native: #02 pc 0000000000511ee0 /apex/com.android.runtime/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+828)
03-19 12:08:40.161 948 948 F zygote64: runtime.cc:630] native: #03 pc 000000000050ad04 /apex/com.android.runtime/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+456)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #04 pc 000000000050a1e8 /apex/com.android.runtime/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+1964)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #05 pc 00000000004b74e8 /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+1452)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #06 pc 000000000000b458 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+580)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #07 pc 00000000003844d4 /apex/com.android.runtime/lib64/libart.so (art::JNI::FatalError(_JNIEnv*, char const*)+196)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #08 pc 00000000001b3fec /system/lib64/libandroid_runtime.so ((anonymous namespace)::ZygoteFailure(_JNIEnv*, char const*, _jstring*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)+160)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #09 pc 00000000001b9fb4 /system/lib64/libandroid_runtime.so (FileDescriptorInfo::CreateFromFd(int, std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)> const&)+1040)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #10 pc 00000000001bacf0 /system/lib64/libandroid_runtime.so (FileDescriptorTable::Create(std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)> const&)+396)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #11 pc 00000000001b4690 /system/lib64/libandroid_runtime.so ((anonymous namespace)::ForkCommon(_JNIEnv*, bool, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<int, std::__1::allocator<int>> const&)+476)
03-19 12:08:40.162 948 948 F zygote64: runtime.cc:630] native: #12 pc 00000000001b2840 /system/lib64/libandroid_runtime.so (android::com_android_internal_os_Zygote_nativeForkSystemServer(_JNIEnv*, _jclass*, unsigned int, unsigned int, _jintArray*, int, _jobjectArray*, long, long)+504)
03-19 12:08:40.163 948 948 F zygote64: runtime.cc:630] at com.android.internal.os.Zygote.nativeForkSystemServer(Native method)
03-19 12:08:40.163 948 948 F zygote64: runtime.cc:630] at com.android.internal.os.Zygote.forkSystemServer(Zygote.java:340)
03-19 12:08:40.163 948 948 F zygote64: runtime.cc:630] at com.android.internal.os.ZygoteInit.forkSystemServer(ZygoteInit.java:785)
03-19 12:08:40.163 948 948 F zygote64: runtime.cc:630] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908)
art/runtime/jni/jni_internal.cc
中报错导致zygote服务直接挂了
813 static void FatalError(JNIEnv*, const char* msg) {
814 LOG(FATAL) << "JNI FatalError called: " << msg;
815 }
源码调用追踪:
→framework/base/core/jni/fd_utils.cpp
// static
FileDescriptorInfo* FileDescriptorInfo::CreateFromFd(int fd, fail_fn_t fail_fn) {
...
std::string file_path;
const std::string fd_path = android::base::StringPrintf("/proc/self/fd/%d", fd);
if (!android::base::Readlink(fd_path, &file_path)) {
fail_fn(android::base::StringPrintf("Could not read fd link %s: %s",
fd_path.c_str(),
strerror(errno)));
}
if (!whitelist->IsAllowed(file_path)) {
fail_fn(std::string("Not whitelisted : ").append(file_path));
}
...
}
→→FileDescriptorTable::Create
frameworks/base/core/jni/com_android_internal_os_Zygote.cpp
→→→ForkCommon
→→→→com_android_internal_os_Zygote_nativeForkSystemServer
解决报错:
1)注释"Not whitelisted : "
错误之后,报新错误:
jni_internal.cc:814] JNI FatalError called: (system_server) Failed open(/proc/23299/status, 0): No such file or directory
runtime.cc:630] Runtime aborting...
runtime.cc:630] Dumping all threads without mutator lock held
runtime.cc:630] All threads:
runtime.cc:630] DALVIK THREADS (1):
runtime.cc:630] "main" prio=5 tid=1 Runnable
runtime.cc:630] | group="" sCount=0 dsCount=0 flags=0 obj=0x71c8ae78 self=0x7122de5c00
runtime.cc:630] | sysTid=18426 nice=0 cgrp=default sched=0/0 handle=0x712434ded0
runtime.cc:630] | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
runtime.cc:630] | stack=0x7fc618e000-0x7fc6190000 stackSize=8192KB
runtime.cc:630] | held mutexes= "abort lock" "mutator lock"(shared held)
runtime.cc:630] kernel: (couldn't read /proc/self/task/18426/stack)
runtime.cc:630] native: (backtrace::Unwind failed for thread 18426: Thread doesn't exist)
runtime.cc:630] at com.android.internal.os.Zygote.nativeForkSystemServer(Native method)
runtime.cc:630] at com.android.internal.os.Zygote.forkSystemServer(Zygote.java:340)
runtime.cc:630] at com.android.internal.os.ZygoteInit.forkSystemServer(ZygoteInit.java:785)
runtime.cc:630] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908)
runtime.cc:630]
runtime.cc:630] Aborting thread:
runtime.cc:630] "main" prio=5 tid=1 Native
runtime.cc:630] | group="" sCount=0 dsCount=0 flags=0 obj=0x71c8ae78 self=0x7122de5c00
runtime.cc:630] | sysTid=18426 nice=0 cgrp=default sched=0/0 handle=0x712434ded0
runtime.cc:630] | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
runtime.cc:630] | stack=0x7fc618e000-0x7fc6190000 stackSize=8192KB
runtime.cc:630] | held mutexes= "abort lock"
runtime.cc:630] kernel: (couldn't read /proc/self/task/18426/stack)
runtime.cc:630] native: (backtrace::Unwind failed for thread 18426: Thread doesn't exist)
runtime.cc:630] at com.android.internal.os.Zygote.nativeForkSystemServer(Native method)
runtime.cc:630] at com.android.internal.os.Zygote.forkSystemServer(Zygote.java:340)
runtime.cc:630] at com.android.internal.os.ZygoteInit.forkSystemServer(ZygoteInit.java:785)
runtime.cc:630] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908)
根据Failed open
日志追溯到源码调用处
→ForkCommon
→→ReopenOrDetach
void FileDescriptorInfo::ReopenOrDetach(fail_fn_t fail_fn) const {
if (is_sock) {
return DetachSocket(fail_fn);
}
// NOTE: This might happen if the file was unlinked after being opened.
// It's a common pattern in the case of temporary files and the like but
// we should not allow such usage from the zygote.
const int new_fd = TEMP_FAILURE_RETRY(open(file_path.c_str(), open_flags));
if (new_fd == -1) {
fail_fn(android::base::StringPrintf("Failed open(%s, %i): %s",
file_path.c_str(),
open_flags,
strerror(errno)));
}
...
}
2) 注释ReopenOrDetach方法之后,报错:
jni_internal.cc:814] JNI FatalError called: (system_server) frameworks/base/core/jni/com_android_internal_os_Zygote.cpp:688: Failed to mount /mnt/runtime/default to /storage: No such file or directory
3)在容器根文件系统中创建storage目录,仍然报错:
Zygote : Exit zygote because system server (pid 1578) has terminated
主要是system_server启动各种服务报错
3-1)原因1:配置文件读取失败,导致PackageManager服务一个空指针问题。
PackageManager: Error reading settings: java.io.FileNotFoundException: /data/system/packages.xml: open failed: EACCES (Permission denied)
System : java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.android.server.pm.Settings$VersionInfo.fingerprint' on a null object reference
AndroidRuntime: Shutting down VM
Zygote : Exit zygote because system server (pid 1850) has terminated
解决办法:
将容器根文件系统里的/data/system/packages.xml
文件用户和组修改成和宿主机里一致,并chmod +rw添加读写权限。
3-2)原因2:UsageStatsService 抛出异常。
3-2-1)
java.lang.RuntimeException: Failed to start service com.android.server.usage.UsageStatsService: onStart threw an exception
System : Caused by: java.lang.IllegalStateException: Failed to create directory /data/system/usagestats/0/daily
System : at com.android.server.usage.UsageStatsDatabase.init(UsageStatsDatabase.java:157)
System : at com.android.server.usage.UserUsageStatsService.init(UserUsageStatsService.java:107)
AndroidRuntime: Shutting down VM
Zygote : Exit zygote because system server (pid 2247) has terminated
UsageStatsDatabase.java
public void init(long currentTimeMillis) {
synchronized (mLock) {
for (File f : mIntervalDirs) {
f.mkdirs();
if (!f.exists()) {
// throw new IllegalStateException("Failed to create directory "
// + f.getAbsolutePath());
Slog.e(TAG,"CZ fix a bug here");
}
}
实际进入容器查看/data/system/usagestats/0/daily
目录已经创建成功,但是源码里却是报错。
3-2-2)/data/system/usagestats/0/version
找不到
System : Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /data/system/usagestats/0/version: open failed: EACCES (Permission denied)
System : at com.android.server.usage.UsageStatsDatabase.checkVersionAndBuildLocked(UsageStatsDatabase.java:379)
System : at com.android.server.usage.UsageStatsDatabase.init(UsageStatsDatabase.java:162)
System : at com.android.server.usage.UserUsageStatsService.init(UserUsageStatsService.java:107)
System : at com.android.server.usage.UsageStatsService.getUserDataAndInitializeIfNeededLocked(UsageStatsService.java:399)
System : at com.android.server.usage.UsageStatsService.onStart(UsageStatsService.java:249)
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:130)
实际容器根文件系统是存在的,chmod +rw给文件的其它用户添加读写权限,并且chown system:system 改变所属用户和组。
3-3)ActivityManagerService 抛出异常。
3-3-1)
AndroidRuntime: java.lang.IllegalStateException: Cannot access system provider: 'settings' before system providers are installed!
AndroidRuntime: at com.android.server.am.ActivityManagerService.getContentProviderImpl(ActivityManagerService.java:7000)
AndroidRuntime: at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7301)
AndroidRuntime: at android.app.ActivityThread.acquireProvider(ActivityThread.java:6602)
AndroidRuntime: at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:2706)
AndroidRuntime: at android.content.ContentResolver.acquireProvider(ContentResolver.java:2104)
AndroidRuntime: at android.provider.Settings$ContentProviderHolder.getProvider(Settings.java:2252)
AndroidRuntime: at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:2347)
AndroidRuntime: at android.provider.Settings$Global.getStringForUser(Settings.java:14153)
AndroidRuntime: at android.provider.Settings$Global.getString(Settings.java:14141)
AndroidRuntime: at android.provider.Settings$Global.getInt(Settings.java:14323)
AndroidRuntime: at com.android.server.am.ActivityManagerService$21.run(ActivityManagerService.java:9655)
AndroidRuntime: at com.android.server.am.ActivityManagerService.addErrorToDropBox(ActivityManagerService.java:9706)
AndroidRuntime: at com.android.server.Watchdog$1.run(Watchdog.java:682)
Zygote : Exit zygote because system server (pid 4581) has terminated
解决办法:将抛出的异常注释掉
// If system providers are not installed yet we aggressively crash to avoid
// creating multiple instance of these providers and then bad things happen!
if (!mSystemProvidersInstalled && cpi.applicationInfo.isSystemApp()
&& "system".equals(cpi.processName)) {
// throw new IllegalStateException("Cannot access system provider: '"
// + cpi.authority + "' before system providers are installed!");
Slog.w(TAG,"CZLog remove IllegalStateException-" + "Cannot access system provider: '"+ cpi.authority + "' before system providers are installed!");
return null;
}
但是这又会导致后续的调用空指针:
AndroidRuntime: Error reporting crash
AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle android.content.IContentProvider.call(java.lang.String, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
AndroidRuntime: at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:2391)
AndroidRuntime: at android.provider.Settings$Global.getStringForUser(Settings.java:14153)
AndroidRuntime: at android.provider.Settings$Global.getString(Settings.java:14141)
AndroidRuntime: at android.provider.Settings$Global.getInt(Settings.java:14323)
AndroidRuntime: at com.android.server.am.ActivityManagerService$21.run(ActivityManagerService.java:9657)
AndroidRuntime: at com.android.server.am.ActivityManagerService.addErrorToDropBox(ActivityManagerService.java:9708)
AndroidRuntime: at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:9326)
AndroidRuntime: at com.android.server.am.ActivityManagerService.handleApplicationCrash(ActivityManagerService.java:9282)
AndroidRuntime: at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:145)
AndroidRuntime: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
AndroidRuntime: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
AndroidRuntime: at java.lang.Thread.dispatchUncaughtException(Thread.java:2187)
上面不能return null
3-3-2)Unable to find app for caller
3-3-2-1)第1处:
Zygote : System zygote died with exception
Zygote : java.lang.SecurityException: Unable to find app for caller android.app.IApplicationThread$Stub$Proxy@5b189e4 (pid=30498) when registering receiver android.content.IIntentReceiver$Stub$Proxy@ef35e4d
Zygote : at android.os.Parcel.createException(Parcel.java:2071)
Zygote : at android.os.Parcel.readException(Parcel.java:2039)
Zygote : at android.os.Parcel.readException(Parcel.java:1987)
Zygote : at android.app.IActivityManager$Stub$Proxy.registerReceiver(IActivityManager.java:4787)
Zygote : at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1527)
Zygote : at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
Zygote : at com.android.server.Watchdog.init(Watchdog.java:356)
Zygote : at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:790)
Zygote : at com.android.server.SystemServer.run(SystemServer.java:515)
Zygote : at com.android.server.SystemServer.main(SystemServer.java:354)
Zygote : at java.lang.reflect.Method.invoke(Native Method)
Zygote : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
Zygote : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
Zygote : Caused by: android.os.RemoteException: Remote stack trace:
Zygote : at com.android.server.am.ActivityManagerService.registerReceiver(ActivityManagerService.java:14481)
Zygote : at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:1886)
Zygote : at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2763)
Zygote : at android.os.Binder.execTransactInternal(Binder.java:1021)
Zygote : at android.os.Binder.execTransact(Binder.java:994)
Zygote :
AndroidRuntime: Shutting down VM
Zygote : Exit zygote because system server (pid 2433) has terminated
找到源码报错位置:
callerApp = getRecordForAppLocked(caller);
if (callerApp == null) {
throw new SecurityException(
"Unable to find app for caller " + caller
+ " (pid=" + Binder.getCallingPid()
+ ") when registering receiver " + receiver);
}
3-3-2-2)第2处:ActivityManagerService.installSystemProviders
注意下面ActivityManagerService与ActivityThread之间的aidl进程交互
System : ******************************************
System : ************ Failure starting core service
System : java.lang.SecurityException: Unable to find app for caller android.app.IApplicationThread$Stub$Proxy@ab730f1 (pid=4342) when publishing content providers
System : at android.os.Parcel.createException(Parcel.java:2071)
System : at android.os.Parcel.readException(Parcel.java:2039)
System : at android.os.Parcel.readException(Parcel.java:1987)
System : at android.app.IActivityManager$Stub$Proxy.publishContentProviders(IActivityManager.java:5083)
System : at android.app.ActivityThread.installContentProviders(ActivityThread.java:6578)
System : at android.app.ActivityThread.installSystemProviders(ActivityThread.java:7210)
System : at com.android.server.am.ActivityManagerService.installSystemProviders(ActivityManagerService.java:7615)
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:990)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : Caused by: android.os.RemoteException: Remote stack trace:
System : at com.android.server.am.ActivityManagerService.publishContentProviders(ActivityManagerService.java:7411)
System : at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2096)
System : at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2763)
System : at android.os.Binder.execTransactInternal(Binder.java:1021)
System : at android.os.Binder.execTransact(Binder.java:994)
System :
System : ******************************************
System : ************ Failure starting system services
System : java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.wm.WindowManagerService.detectSafeMode()' on a null object reference
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:1111)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
SystemServerTiming: InstallSystemProviders took to complete: 19ms
Zygote : System zygote died with exception
源码追溯:
public final void publishContentProviders(IApplicationThread caller,
List<ContentProviderHolder> providers) {
if (providers == null) {
return;
}
enforceNotIsolatedCaller("publishContentProviders");
synchronized (this) {
final ProcessRecord r = getRecordForAppLocked(caller);
if (DEBUG_MU) Slog.v(TAG_MU, "ProcessRecord uid = " + r.uid);
if (r == null) {
throw new SecurityException(
"Unable to find app for caller " + caller
+ " (pid=" + Binder.getCallingPid()
+ ") when publishing content providers");
}
...
}
上面2处报错,最终是因为getRecordForAppLocked(caller)返回null。
ProcessRecord getRecordForAppLocked(IApplicationThread thread) {
if (thread == null) {
return null;
}
ProcessRecord record = mProcessList.getLRURecordForAppLocked(thread);
if (record != null) return record;
// Validation: if it isn't in the LRU list, it shouldn't exist, but let's
// double-check that.
final IBinder threadBinder = thread.asBinder();
final ArrayMap<String, SparseArray<ProcessRecord>> pmap =
mProcessList.mProcessNames.getMap();
for (int i = pmap.size()-1; i >= 0; i--) {
final SparseArray<ProcessRecord> procs = pmap.valueAt(i);
for (int j = procs.size()-1; j >= 0; j--) {
final ProcessRecord proc = procs.valueAt(j);
if (proc.thread != null && proc.thread.asBinder() == threadBinder) {
Slog.wtf(TAG, "getRecordForApp: exists in name list but not in LRU list: "
+ proc);
return proc;
}
}
}
return null;
}
果然还是和binder扯上了关系。
3-4)启动VibratorService失败
SystemServer: StartVibratorService
Process : Sending signal. PID: 2009 SIG: 9
...
Zygote : Process 2009 exited due to signal 9 (Killed)
Zygote : Exit zygote because system server (pid 2009) has terminated
一时找不到原因,先不启动这个服务。
3-4)启动AccountManagerService失败
SystemServer: StartAccountManagerService
SystemServiceManager: Starting com.android.server.accounts.AccountManagerService$Lifecycle
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: RollbackManagerServiceHandler
AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
AndroidRuntime: at com.android.server.rollback.RollbackStore.loadAllRollbackData(RollbackStore.java:81)
AndroidRuntime: at com.android.server.rollback.RollbackManagerServiceImpl.loadAllRollbackDataLocked(RollbackManagerServiceImpl.java:709)
AndroidRuntime: at com.android.server.rollback.RollbackManagerServiceImpl.ensureRollbackDataLoadedLocked(RollbackManagerServiceImpl.java:697)
AndroidRuntime: at com.android.server.rollback.RollbackManagerServiceImpl.ensureRollbackDataLoaded(RollbackManagerServiceImpl.java:686)
AndroidRuntime: at com.android.server.rollback.RollbackManagerServiceImpl.lambda$new$0$RollbackManagerServiceImpl(RollbackManagerServiceImpl.java:161)
AndroidRuntime: at com.android.server.rollback.-$$Lambda$RollbackManagerServiceImpl$2_NDf9EpLcTKkJVpkadZhudKips.run(Unknown Source:2)
AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
SystemServerTiming: StartAccountManagerService took to complete: 27ms
SystemServer: StartContentService
SystemServiceManager: Starting com.android.server.content.ContentService$Lifecycle
SystemServerInitThreadPool: Started executing SecondaryZygotePreload
SystemServer: SecondaryZygotePreload
Process : Sending signal. PID: 3229 SIG: 9
lowmemorykiller: lmkd data connection dropped
lowmemorykiller: closing lmkd data connection
Zygote : Process 3229 exited due to signal 9 (Killed)
Zygote : Exit zygote because system server (pid 3229) has terminated
3-5)StartLightsService失败
Watchdog: First set of traces were collected more than 5 minutes ago, ignoring ...
Watchdog: Second set of traces taken from /data/anr/anr_2024-03-19-11-25-30-358
Watchdog: *** WATCHDOG KILLING SYSTEM PROCESS: Blocked in handler on main thread (main)
Watchdog: main annotated stack trace:
Watchdog: at android.view.SurfaceControl.nativeGetPhysicalDisplayIds(Native Method)
Watchdog: at android.view.SurfaceControl.getPhysicalDisplayIds(SurfaceControl.java:1810)
Watchdog: at android.view.SurfaceControl.getInternalDisplayToken(SurfaceControl.java:1826)
Watchdog: at com.android.server.lights.LightsService$LightImpl.<init>(LightsService.java:44)
Watchdog: at com.android.server.lights.LightsService$LightImpl.<init>(LightsService.java:37)
Watchdog: at com.android.server.lights.LightsService.<init>(LightsService.java:211)
Watchdog: at java.lang.reflect.Constructor.newInstance0(Native Method)
Watchdog: at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
Watchdog: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:102)
Watchdog: at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:702)
Watchdog: at com.android.server.SystemServer.run(SystemServer.java:515)
Watchdog: at com.android.server.SystemServer.main(SystemServer.java:354)
Watchdog: at java.lang.reflect.Method.invoke(Native Method)
Watchdog: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
Watchdog: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
Watchdog: *** GOODBYE!
Process : Sending signal. PID: 2049 SIG: 9
Zygote : Process 2049 exited due to signal 9 (Killed)
Zygote : Exit zygote because system server (pid 2049) has terminated
3-6)StartUsageService失败
SystemServer: StartUsageService
SystemServiceManager: Starting com.android.server.usage.UsageStatsService
System : ******************************************
System : ************ Failure starting system services
System : java.lang.RuntimeException: Failed to start service com.android.server.usage.UsageStatsService: onStart threw an exception
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:132)
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:117)
System : at com.android.server.SystemServer.startCoreServices(SystemServer.java:836)
System : at com.android.server.SystemServer.run(SystemServer.java:516)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : Caused by: java.lang.RuntimeException: android.os.DeadSystemException
System : at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1536)
System : at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
System : at android.app.ContextImpl.registerReceiver(ContextImpl.java:1476)
System : at com.android.server.usage.AppStandbyController.<init>(AppStandbyController.java:337)
System : at com.android.server.usage.AppStandbyController.<init>(AppStandbyController.java:324)
System : at com.android.server.usage.UsageStatsService.onStart(UsageStatsService.java:189)
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:130)
System : ... 7 more
System : Caused by: android.os.DeadSystemException
System : ... 14 more
SystemServerTiming: StartUsageService took to complete: 3ms
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
AndroidRuntime: DeadSystemException: The system died; earlier logs will point to the root cause
注意这里的android.os.DeadSystemException,先排除修改代码的地方会不会造成空指针异常。
3-7) SystemServer: InstallSystemProviders 之后
System : ******************************************
System : ************ Failure starting core service
System : java.lang.IllegalStateException: cannot interact with a closed instance
System : at android.util.MemoryIntArray.enforceNotClosed(MemoryIntArray.java:207)
System : at android.util.MemoryIntArray.get(MemoryIntArray.java:106)
System : at android.provider.Settings$GenerationTracker.readCurrentGeneration(Settings.java:2213)
System : at android.provider.Settings$GenerationTracker.isGenerationChanged(Settings.java:2197)
System : at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:2327)
System : at android.provider.Settings$Global.getStringForUser(Settings.java:14153)
System : at android.provider.Settings$Global.getString(Settings.java:14141)
System : at com.android.server.am.ActivityManagerConstants.updateConstants(ActivityManagerConstants.java:430)
System : at com.android.server.am.ActivityManagerConstants.start(ActivityManagerConstants.java:372)
System : at com.android.server.am.ActivityManagerService.installSystemProviders(ActivityManagerService.java:7635)
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:990)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : ******************************************
System : ************ Failure starting system services
System : java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.wm.WindowManagerService.detectSafeMode()' on a null object reference
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:1111)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
SystemServerTiming: InstallSystemProviders took to complete: 31ms
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.wm.WindowManagerService.detectSafeMode()' on a null object reference
对应源码frameworks/base/core/java/android/util/MemoryIntArray.java +106:
98 /**
99 * Gets the value at a given index.
100 *
101 * @param index The index.
102 * @return The value at this index.
103 * @throws IOException If an error occurs while accessing the shared memory.
104 */
105 public int get(int index) throws IOException {
106 enforceNotClosed();
107 enforceValidIndex(index);
108 return nativeGet(mFd, mMemoryAddr, index);
109 }
...
205 private void enforceNotClosed() {
206 if (isClosed()) {
207 throw new IllegalStateException("cannot interact with a closed instance");
208 }
209 }
解决办法:注释抛出异常的地方
private void enforceNotClosed() {
/*if (isClosed()) {
throw new IllegalStateException("cannot interact with a closed instance");
}*/
}
3-8)替换了主机的services.jar以后,云机新报错。
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: AudioService
AndroidRuntime: java.lang.IllegalStateException: Cannot broadcast before boot completed
AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2079)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2039)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1987)
AndroidRuntime: at android.app.IActivityManager$Stub$Proxy.broadcastIntent(IActivityManager.java:4862)
AndroidRuntime: at android.app.ContextImpl.sendStickyBroadcastAsUser(ContextImpl.java:1398)
AndroidRuntime: at com.android.server.audio.BtHelper.sendStickyBroadcastToAll(BtHelper.java:1113)
AndroidRuntime: at com.android.server.audio.BtHelper.onSystemReady(BtHelper.java:211)
AndroidRuntime: at com.android.server.audio.AudioDeviceBroker.onSystemReady(AudioDeviceBroker.java:130)
AndroidRuntime: at com.android.server.audio.AudioService.onSystemReady(AudioService.java:877)
AndroidRuntime: at com.android.server.audio.AudioService$AudioHandler.handleMessage(AudioService.java:5541)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
AndroidRuntime: at com.android.server.audio.AudioService$AudioSystemThread.run(AudioService.java:5066)
AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
AndroidRuntime: at com.android.server.am.ActivityManagerService.verifyBroadcastLocked(ActivityManagerService.java:15625)
AndroidRuntime: at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:15657)
AndroidRuntime: at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:1950)
AndroidRuntime: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2763)
AndroidRuntime: at android.os.Binder.execTransactInternal(Binder.java:1021)
AndroidRuntime:
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: AudioDeviceBroker
AndroidRuntime: java.lang.IllegalStateException: Cannot broadcast before boot completed
AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2079)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2039)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1987)
AndroidRuntime: at android.app.IActivityManager$Stub$Proxy.broadcastIntent(IActivityManager.java:4862)
AndroidRuntime: at android.app.ContextImpl.sendStickyBroadcastAsUser(ContextImpl.java:1398)
AndroidRuntime: at com.android.server.audio.BtHelper.sendStickyBroadcastToAll(BtHelper.java:1113)
AndroidRuntime: at com.android.server.audio.BtHelper.onBroadcastScoConnectionState(BtHelper.java:560)
AndroidRuntime: at com.android.server.audio.AudioDeviceBroker$BrokerHandler.handleMessage(AudioDeviceBroker.java:750)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
AndroidRuntime: at com.android.server.audio.AudioDeviceBroker$BrokerThread.run(AudioDeviceBroker.java:726)
AppBindingService: Updating constants with: null
Process : Sending signal. PID: 2189 SIG: 9
3-8-1)注释上述错误之后,StartWebViewUpdateService报错:
ZygoteProcess: IO Exception while communicating with Zygote - java.io.EOFException
ZygoteProcess: Starting VM process through Zygote failed
ActivityManager: Failure starting process WebViewLoader-armeabi-v7a
ActivityManager: java.lang.RuntimeException: Starting VM process through Zygote failed
ActivityManager: at android.os.ZygoteProcess.start(ZygoteProcess.java:340)
ActivityManager: at android.os.Process.start(Process.java:534)
ActivityManager: at com.android.server.am.ProcessList.startProcess(ProcessList.java:1826)
ActivityManager: at com.android.server.am.ProcessList.lambda$startProcessLocked$0$ProcessList(
ActivityManager: at com.android.server.am.-$$Lambda$ProcessList$vtq7LF5jIHO4t5NE03c8g7BT7Jc.ru
ActivityManager: at android.os.Handler.handleCallback(Handler.java:883)
ActivityManager: at android.os.Handler.dispatchMessage(Handler.java:100)
ActivityManager: at android.os.Looper.loop(Looper.java:214)
ActivityManager: at android.os.HandlerThread.run(HandlerThread.java:67)
ActivityManager: at com.android.server.ServiceThread.run(ServiceThread.java:44)
ActivityManager: Caused by: android.os.ZygoteStartFailedEx: java.io.EOFException
ActivityManager: at android.os.ZygoteProcess.attemptZygoteSendArgsAndGetResult(ZygoteProcess.j
ActivityManager: at android.os.ZygoteProcess.zygoteSendArgsAndGetResult(ZygoteProcess.java:419
ActivityManager: at android.os.ZygoteProcess.startViaZygote(ZygoteProcess.java:635)
ActivityManager: at android.os.ZygoteProcess.start(ZygoteProcess.java:333)
ActivityManager: ... 9 more
ActivityManager: Caused by: java.io.EOFException
ActivityManager: at java.io.DataInputStream.readFully(DataInputStream.java:200)
ActivityManager: at java.io.DataInputStream.readInt(DataInputStream.java:389)
ActivityManager: at android.os.ZygoteProcess.attemptZygoteSendArgsAndGetResult(ZygoteProcess.j
ActivityManager: ... 12 more
ActivityManager: Force stopping android appid=1037 user=0: start failure
ActivityManager: Killing 0:WebViewLoader-arm64-v8a/1037 (adj -10000): stop android
system_server: Long monitor contention with owner ActivityManager:procStart (1433) at int androi
WebViewZygote: Error connecting to webview zygote
WebViewZygote: java.lang.RuntimeException: Starting child-zygote through Zygote failed
WebViewZygote: at android.os.ZygoteProcess.startChildZygote(ZygoteProcess.java:1149)
WebViewZygote: at android.webkit.WebViewZygote.connectToZygoteIfNeededLocked(WebViewZygote.j
WebViewZygote: at android.webkit.WebViewZygote.getProcess(WebViewZygote.java:62)
WebViewZygote: at com.android.server.webkit.SystemImpl.ensureZygoteStarted(SystemImpl.java:2
WebViewZygote: at com.android.server.webkit.WebViewUpdateServiceImpl.startZygoteWhenReady(We
WebViewZygote: at com.android.server.webkit.-$$Lambda$lAUGMGZZth095wGxrAtUYbmlIJY.run(Unknow
WebViewZygote: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:
WebViewZygote: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java
WebViewZygote: at java.lang.Thread.run(Thread.java:919)
WebViewZygote: Caused by: android.os.ZygoteStartFailedEx: Error connecting to zygote
WebViewZygote: at android.os.ZygoteProcess.openZygoteSocketIfNeeded(ZygoteProcess.java:923)
WebViewZygote: at android.os.ZygoteProcess.startViaZygote(ZygoteProcess.java:635)
WebViewZygote: at android.os.ZygoteProcess.startChildZygote(ZygoteProcess.java:1143)
WebViewZygote: ... 8 more
WebViewZygote: Caused by: java.io.IOException: Connection refused
WebViewZygote: at android.net.LocalSocketImpl.connectLocal(Native Method)
WebViewZygote: at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:296)
WebViewZygote: at android.net.LocalSocket.connect(LocalSocket.java:147)
WebViewZygote: at android.os.ZygoteProcess$ZygoteState.connect(ZygoteProcess.java:188)
WebViewZygote: at android.os.ZygoteProcess.attemptConnectionToSecondaryZygote(ZygoteProcess.
WebViewZygote: at android.os.ZygoteProcess.openZygoteSocketIfNeeded(ZygoteProcess.java:916)
WebViewZygote: ... 10 more
3-9)
statsd : statscompanion service died
statsd : Reset statsd upon system server restarts.
System : ******************************************
System : ************ Failure starting system services
System : java.lang.RuntimeException: Failed to boot service com.android.server.wallpaper.WallpaperManagerService$Lifecycle: onBootPhase threw an exception during phase 600
System : at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:162)
System : at com.android.server.SystemServer.lambda$startOtherServices$4$SystemServer(SystemServer.java:2224)
System : at com.android.server.-$$Lambda$SystemServer$RIWNR87PnJ4Y6VHItRXU0J6ocqQ.run(Unknown Source:53)
System : at com.android.server.am.ActivityManagerService.systemReady(ActivityManagerService.java:9102)
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:2105)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : Caused by: java.lang.RuntimeException: android.os.DeadSystemException
System : at android.hardware.display.DisplayManagerGlobal.getDisplayIds(DisplayManagerGlobal.java:183)
System : at android.hardware.display.DisplayManager.getDisplays(DisplayManager.java:359)
System : at android.hardware.display.DisplayManager.getDisplays(DisplayManager.java:339)
System : at com.android.server.wallpaper.WallpaperManagerService$WallpaperConnection.appendConnectorWithCondition(WallpaperManagerService.java:1210)
System : at com.android.server.wallpaper.WallpaperManagerService$WallpaperConnection.initDisplayState(WallpaperManagerService.java:1199)
System : at com.android.server.wallpaper.WallpaperManagerService$WallpaperConnection.<init>(WallpaperManagerService.java:1191)
System : at com.android.server.wallpaper.WallpaperManagerService.bindWallpaperComponentLocked(WallpaperManagerService.java:2704)
System : at com.android.server.wallpaper.WallpaperManagerService.switchWallpaper(WallpaperManagerService.java:1873)
System : at com.android.server.wallpaper.WallpaperManagerService.switchUser(WallpaperManagerService.java:1856)
System : at com.android.server.wallpaper.WallpaperManagerService.onBootPhase(WallpaperManagerService.java:1787)
System : at com.android.server.wallpaper.WallpaperManagerService$Lifecycle.onBootPhase(WallpaperManagerService.java:164)
System : at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:159)
System : ... 9 more
System : Caused by: android.os.DeadSystemException
System : ... 21 more
SystemServerTiming: PhaseThirdPartyAppsCanStart took to complete: 150ms
SystemUIBootTiming: StartServicescom.android.systemui.util.NotificationChannels took to complete: 6ms
Zygote : System zygote died with exception
Zygote : DeadSystemException: The system died; earlier logs will point to the root cause
AndroidRuntime: Shutting down VM
statscompanion service died
报错位置:frameworks/base/cmds/statsd/src/StatsService.cpp:1582
导致SystemServer重启,进而导致android.os.DeadSystemException
异常产生。
3-10)
System : ******************************************
System : ************ Failure starting system services
System : java.lang.NullPointerException: Attempt to read from field 'android.content.pm.ApplicationInfo android.content.pm.PackageInfo.applicationInfo' on a null object reference
System : at com.android.server.om.IdmapManager.idmapExists(IdmapManager.java:122)
System : at com.android.server.om.OverlayManagerServiceImpl.calculateNewState(OverlayManagerServiceImpl.java:731)
System : at com.android.server.om.OverlayManagerServiceImpl.updateState(OverlayManagerServiceImpl.java:696)
System : at com.android.server.om.OverlayManagerServiceImpl.updateOverlaysForUser(OverlayManagerServiceImpl.java:190)
System : at com.android.server.om.OverlayManagerService.onSwitchUser(OverlayManagerService.java:303)
System : at com.android.server.om.OverlayManagerService.<init>(OverlayManagerService.java:264)
System : at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:799)
System : at com.android.server.SystemServer.run(SystemServer.java:515)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
3-11)
SystemServer: ***********************************************
SystemServer: BOOT FAILURE making Display Manager Service ready
SystemServer: DeadSystemException: The system died; earlier logs will point to the root cause
3-12)
SystemServer: StartRestrictionManager
SystemServiceManager: Starting com.android.server.restrictions.RestrictionsManagerService
System : ******************************************
System : ************ Failure starting system services
System : java.lang.RuntimeException: Failed to create service com.android.server.restrictions.RestrictionsManagerService: service constructor threw an exception
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:113)
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:1757)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : Caused by: java.lang.reflect.InvocationTargetException
System : at java.lang.reflect.Constructor.newInstance0(Native Method)
System : at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:102)
System : ... 6 more
System : Caused by: java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.os.IUserManager
System : at com.android.server.restrictions.RestrictionsManagerService$RestrictionsManagerImpl.<init>(RestrictionsManagerService.java:66)
System : at com.android.server.restrictions.RestrictionsManagerService.<init>(RestrictionsManagerService.java:51)
System : ... 9 more
SystemServerTiming: StartRestrictionManager took to complete: 15ms
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
AndroidRuntime: java.lang.RuntimeException: Failed to create service com.android.server.restrictions.RestrictionsManagerService: service constructor threw an exception
AndroidRuntime: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:113)
AndroidRuntime: at com.android.server.SystemServer.startOtherServices(SystemServer.java:1757)
AndroidRuntime: at com.android.server.SystemServer.run(SystemServer.java:517)
AndroidRuntime: at com.android.server.SystemServer.main(SystemServer.java:354)
AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
AndroidRuntime: at java.lang.reflect.Constructor.newInstance0(Native Method)
AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
AndroidRuntime: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:102)
AndroidRuntime: ... 6 more
AndroidRuntime: Caused by: java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.os.IUserManager
AndroidRuntime: at com.android.server.restrictions.RestrictionsManagerService$RestrictionsManagerImpl.<init>(RestrictionsManagerService.java:66)
AndroidRuntime: at com.android.server.restrictions.RestrictionsManagerService.<init>(RestrictionsManagerService.java:51)
AndroidRuntime: ... 9 more
3-13)
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
AndroidRuntime: java.lang.RuntimeException: Failed to create service com.android.server.inputmethod.InputMethodManagerService$Lifecycle: service constructor threw an exception
AndroidRuntime: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:113)
AndroidRuntime: at com.android.server.SystemServer.startOtherServices(SystemServer.java:1135)
AndroidRuntime: at com.android.server.SystemServer.run(SystemServer.java:517)
AndroidRuntime: at com.android.server.SystemServer.main(SystemServer.java:354)
AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
AndroidRuntime: at java.lang.reflect.Constructor.newInstance0(Native Method)
AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
AndroidRuntime: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:102)
AndroidRuntime: ... 6 more
AndroidRuntime: Caused by: java.lang.ClassCastException: android.os.IUserManager$Stub$Proxy cannot be cast to com.android.server.pm.UserManagerService
AndroidRuntime: at com.android.server.am.UserController$Injector.getUserManager(UserController.java:2295)
AndroidRuntime: at com.android.server.am.UserController.getUserInfo(UserController.java:1944)
AndroidRuntime: at com.android.server.am.UserController.getCurrentUser(UserController.java:1897)
AndroidRuntime: at com.android.server.am.ActivityManagerService.getCurrentUser(ActivityManagerService.java:17692)
AndroidRuntime: at com.android.server.inputmethod.InputMethodManagerService.<init>(InputMethodManagerService.java:1494)
AndroidRuntime: at com.android.server.inputmethod.InputMethodManagerService$Lifecycle.<init>(InputMethodManagerService.java:1383)
3-14)ContextImpl.java报错
3-14-1)
System : ************ Failure starting system services
System : java.lang.RuntimeException: android.os.DeadSystemException
System : at android.app.ContextImpl.checkPermission(ContextImpl.java:1837)
System : at android.app.ContextImpl.checkCallingOrSelfPermission(ContextImpl.java:1875)
System : at android.content.ContextWrapper.checkCallingOrSelfPermission(ContextWrapper.java:778)
System : at android.provider.DeviceConfig.enforceReadPermission(DeviceConfig.java:803)
System : at android.provider.DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.java:623)
System : at com.android.server.am.ActivityManagerService$HiddenApiSettings.registerObserver(ActivityManagerService.java:2356)
System : at com.android.server.am.ActivityManagerService.retrieveSettings(ActivityManagerService.java:8998)
System : at com.android.server.am.ActivityManagerService.systemReady(ActivityManagerService.java:9089)
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:2105)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : Caused by: android.os.DeadSystemException
3-14-2)
SystemServer: MakeDisplayReady
SystemServer: ***********************************************
SystemServer: BOOT FAILURE making display ready
SystemServer: java.lang.NullPointerException: Attempt to read from field 'boolean com.android.server.wm.DisplayContent.mDisplayScalingDisabled' on a nu
SystemServer: at com.android.server.wm.WindowManagerService.applyForcedPropertiesForDefaultDisplay(WindowManagerService.java:5137)
SystemServer: at com.android.server.wm.WindowManagerService.displayReady(WindowManagerService.java:4491)
SystemServer: at com.android.server.SystemServer.startOtherServices(SystemServer.java:1150)
SystemServer: at com.android.server.SystemServer.run(SystemServer.java:517)
SystemServer: at com.android.server.SystemServer.main(SystemServer.java:354)
SystemServer: at java.lang.reflect.Method.invoke(Native Method)
SystemServer: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
SystemServer: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
SystemServerTiming: MakeDisplayReady took to complete: 4ms
SystemServer: StartStorageManagerService
SystemServiceManager: Starting com.android.server.StorageManagerService$Lifecycle
SystemServer: ***********************************************
SystemServer: BOOT FAILURE starting StorageManagerService
SystemServer: DeadSystemException: The system died; earlier logs will point to the root cause
SystemServerTiming: StartStorageManagerService took to complete: 11ms
SystemServer: StartStorageStatsService
SystemServiceManager: Starting com.android.server.usage.StorageStatsService$Lifecycle
SystemServiceRegistry: No service published for: mount
SystemServiceRegistry: android.os.ServiceManager$ServiceNotFoundException: No service published for: mount
SystemServiceRegistry: at android.os.ServiceManager.getServiceOrThrow(ServiceManager.java:148)
SystemServiceRegistry: at android.os.storage.StorageManager.<init>(StorageManager.java:505)
SystemServiceRegistry: at android.app.SystemServiceRegistry$42.createService(SystemServiceRegistry.java:580)
SystemServiceRegistry: at android.app.SystemServiceRegistry$42.createService(SystemServiceRegistry.java:577)
SystemServiceRegistry: at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:1402)
SystemServiceRegistry: at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:1318)
SystemServiceRegistry: at android.app.ContextImpl.getSystemService(ContextImpl.java:1805)
SystemServiceRegistry: at android.content.Context.getSystemService(Context.java:3457)
SystemServiceRegistry: at com.android.server.usage.StorageStatsService.<init>(StorageStatsService.java:109)
SystemServiceRegistry: at com.android.server.usage.StorageStatsService$Lifecycle.onStart(StorageStatsService.java:89)
SystemServiceRegistry: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:130)
SystemServiceRegistry: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:117)
SystemServiceRegistry: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:76)
SystemServiceRegistry: at com.android.server.SystemServer.startOtherServices(SystemServer.java:1174)
SystemServiceRegistry: at com.android.server.SystemServer.run(SystemServer.java:517)
SystemServiceRegistry: at com.android.server.SystemServer.main(SystemServer.java:354)
SystemServiceRegistry: at java.lang.reflect.Method.invoke(Native Method)
SystemServiceRegistry: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
SystemServiceRegistry: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
SystemServer: ***********************************************
SystemServer: BOOT FAILURE starting StorageStatsService
SystemServer: java.lang.RuntimeException: Failed to start service com.android.server.usage.StorageStatsService$Lifecycle: onStart threw an exception
SystemServer: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:132)
SystemServer: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:117)
SystemServer: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:76)
SystemServer: at com.android.server.SystemServer.startOtherServices(SystemServer.java:1174)
SystemServer: at com.android.server.SystemServer.run(SystemServer.java:517)
SystemServer: at com.android.server.SystemServer.main(SystemServer.java:354)
SystemServer: at java.lang.reflect.Method.invoke(Native Method)
SystemServer: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
SystemServer: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
SystemServer: Caused by: java.lang.NullPointerException
SystemServer: at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:115)
SystemServer: at com.android.server.usage.StorageStatsService.<init>(StorageStatsService.java:109)
SystemServer: at com.android.server.usage.StorageStatsService$Lifecycle.onStart(StorageStatsService.java:89)
SystemServer: at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:130)
SystemServer: ... 8 more
SystemServerTiming: StartStorageStatsService took to complete: 5ms
SystemServer: StartUiModeManager
SystemServiceManager: Starting com.android.server.UiModeManagerService
System : ******************************************
System : ************ Failure starting system services
System : java.lang.RuntimeException: Failed to start service com.android.server.UiModeManagerService: onStart threw an exception
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:132)
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:117)
System : at com.android.server.SystemServer.startOtherServices(SystemServer.java:1185)
System : at com.android.server.SystemServer.run(SystemServer.java:517)
System : at com.android.server.SystemServer.main(SystemServer.java:354)
System : at java.lang.reflect.Method.invoke(Native Method)
System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
System : Caused by: java.lang.RuntimeException: android.os.DeadSystemException
System : at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1536)
System : at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
System : at android.app.ContextImpl.registerReceiver(ContextImpl.java:1476)
System : at com.android.server.UiModeManagerService.onStart(UiModeManagerService.java:305)
System : at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:130)
System : ... 7 more
System : Caused by: android.os.DeadSystemException
System : ... 12 more
SystemServerTiming: StartUiModeManager took to complete: 3ms
Zygote : System zygote died with exception
Zygote : DeadSystemException: The system died; earlier logs will point to the root cause
AndroidRuntime: Shutting down VM
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
4)Watchdog杀死了主进程
Watchdog: First set of traces were collected more than 5 minutes ago, ignoring ...
Watchdog: Second set of traces taken from /data/anr/anr_2024-03-19-11-11-51-374
Watchdog: *** WATCHDOG KILLING SYSTEM PROCESS: Blocked in handler on main thread (main)
Watchdog: main annotated stack trace:
Watchdog: at com.android.server.display.DisplayManagerService.onBootPhase(DisplayManagerService.java:376)
Watchdog: - waiting to lock <0x061e3deb> (a com.android.server.display.DisplayManagerService$SyncRoot)
Watchdog: at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:159)
Watchdog: at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:720)
Watchdog: at com.android.server.SystemServer.run(SystemServer.java:515)
Watchdog: at com.android.server.SystemServer.main(SystemServer.java:354)
Watchdog: at java.lang.reflect.Method.invoke(Native Method)
Watchdog: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
Watchdog: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:913)
Watchdog: *** GOODBYE!
对应源码Watchdog.java:
Slog.w(TAG, "*** WATCHDOG KILLING SYSTEM PROCESS: " + subject);
WatchdogDiagnostics.diagnoseCheckers(blockedCheckers);
Slog.w(TAG, "*** GOODBYE!");
Process.killProcess(Process.myPid());
System.exit(10);
5)替换/dev/binder驱动为/dev/binder_pad之后的报错
5-1)
AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: backup-0
AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
AndroidRuntime: at com.android.server.backup.DataChangedJournal.listJournals(DataChangedJournal.java:142)
AndroidRuntime: at com.android.server.backup.UserBackupManagerService.parseLeftoverJournals(UserBackupManagerService.java:1086)
AndroidRuntime: at com.android.server.backup.UserBackupManagerService.lambda$_gNqJq9Ygtc0ZVwYhCSDKCUKrKY(Unknown Source:0)
AndroidRuntime: at com.android.server.backup.-$$Lambda$UserBackupManagerService$_gNqJq9Ygtc0ZVwYhCSDKCUKrKY.run(Unknown Source:2)
AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
解决办法:增加null判断
137 /**
138 * Returns a list of journals in the given journal directory.
139 */
140 static ArrayList<DataChangedJournal> listJournals(File journalDirectory) {
141 ArrayList<DataChangedJournal> journals = new ArrayList<>();
142 if (journalDirectory == null) {return journals;}
143 if (journalDirectory.listFiles() == null){return journals;}
144 for (File file : journalDirectory.listFiles()) {
145 journals.add(new DataChangedJournal(file));
146 }
147 return journals;
148 }
5-2)Zygote fork的时候重启
zygote : jni_internal.cc:814] JNI FatalError called: (zygote) Not whitelisted : /proc/10429/status
zygote : runtime.cc:630] Runtime aborting...
zygote : runtime.cc:630] Dumping all threads without mutator lock held
zygote : runtime.cc:630] All threads:
zygote : runtime.cc:630] DALVIK THREADS (1):
zygote : runtime.cc:630] "main" prio=5 tid=1 Runnable
zygote : runtime.cc:630] | group="" sCount=0 dsCount=0 flags=0 obj=0x720c6478 self=0xf1532e00
zygote : runtime.cc:630] | sysTid=93 nice=0 cgrp=default sched=0/0 handle=0xf1924dc0
zygote : runtime.cc:630] | state=R schedstat=( 1172804757 707966986 1704 ) utm=57 stm=59 core=6 HZ=100
zygote : runtime.cc:630] | stack=0xff7a1000-0xff7a3000 stackSize=8192KB
zygote : runtime.cc:630] | held mutexes= "abort lock" "mutator lock"(shared held)
zygote : runtime.cc:630] native: #00 pc 00306d87 /apex/com.android.runtime/lib/libart.so (art::DumpNativeStack(std
zygote : runtime.cc:630] native: #01 pc 003b434b /apex/com.android.runtime/lib/libart.so (art::Thread::DumpStack(s
zygote : runtime.cc:630] native: #02 pc 003b095f /apex/com.android.runtime/lib/libart.so (art::Thread::Dump(std::_
zygote : runtime.cc:630] native: #03 pc 003c9b83 /apex/com.android.runtime/lib/libart.so (art::DumpCheckpoint::Run
zygote : runtime.cc:630] native: #04 pc 003c41fb /apex/com.android.runtime/lib/libart.so (art::ThreadList::RunChec
zygote : runtime.cc:630] native: #05 pc 003c3901 /apex/com.android.runtime/lib/libart.so (art::ThreadList::Dump(st
zygote : runtime.cc:630] native: #06 pc 003829ef /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char
zygote : runtime.cc:630] native: #07 pc 000084b5 /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+
zygote : runtime.cc:630] native: #08 pc 00297513 /apex/com.android.runtime/lib/libart.so (art::JNI::FatalError(_JN
zygote : runtime.cc:630] native: #09 pc 0012e235 /system/lib/libandroid_runtime.so ((anonymous namespace)::ZygoteF
zygote : runtime.cc:630] native: #10 pc 00132467 /system/lib/libandroid_runtime.so (FileDescriptorInfo::CreateFrom
zygote : runtime.cc:630] native: #11 pc 00132f57 /system/lib/libandroid_runtime.so (FileDescriptorTable::Create(st
zygote : runtime.cc:630] native: #12 pc 0012e6c9 /system/lib/libandroid_runtime.so ((anonymous namespace)::ForkCom
zygote : runtime.cc:630] native: #13 pc 0012ceb1 /system/lib/libandroid_runtime.so (android::com_android_internal_
zygote : runtime.cc:630] at com.android.internal.os.Zygote.nativeForkAndSpecialize(Native method)
zygote : runtime.cc:630] at com.android.internal.os.Zygote.forkAndSpecialize(Zygote.java:241)
zygote : runtime.cc:630] at com.android.internal.os.ZygoteConnection.processOneCommand(ZygoteConnection.java:267)
zygote : runtime.cc:630] at com.android.internal.os.ZygoteServer.runSelectLoop(ZygoteServer.java:456)
zygote : runtime.cc:630] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
12.AndroidVM 无法启动
编译services.jar替换到容器/system/framework下,会报错如下。
zygote64: GenerateImage: /system/bin/dex2oat --runtime-arg -Xbootclasspath:/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/qcom.fmradio.jar:/system/framework/com.nxp.nfc.nq.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/system/framework/WfdCommon.jar --image=/data/dalvik-cache/arm64/system@framework@boot.art --dex-file=/apex/com.android.runtime/javalib/core-oj.jar --dex-location=/apex/com.android.runtime/javalib/core-oj.jar --dex-file=/apex/com.android.runtime/javalib/core-libart.jar --dex-location=/apex/com.android.
zygote64: Could not create image space with image file '/system/framework/boot.art'. Attempting to fall back to imageless running. Error was: Cannot compile image to /data/dalvik-cache/arm64/system@framework@boot.art: Failed execv(/system/bin/dex2oat --runtime-arg -Xbootclasspath:/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/qcom.fmradio.jar:/system/framework/com.nxp.nfc.nq.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/system/framework/WfdCommon.jar --image=/data/dalvik-cache/arm64/system@framework@boot.art --dex-
解决办法:
将宿主的framework文件夹拷贝到容器里,然后替换自己的一些文件,注意替换services.jar时services.jar.prof也要一起替换。
13.AndroidVM不断重启
AndroidRuntime: >>>>>> START com.android.internal.os.ZygoteInit uid 0 <<<<<<
重新编译framework.jar替换以后就这样,没有做什么重大的修改,怀疑是系统校验的问题。
二、lxc-attach命令
1.Failed to execute shell
lxc-attach android1 20240319110136.561 INFO attach - attach.c:lxc_attach_run_shell:1492 - CZLog lxc_attach_run_shell,user_shell:/system/bin/sh
lxc-attach android1 20240319110136.564 INFO attach - attach.c:lxc_attach_run_shell:1495 - CZLog user_shell_exe_result:-1
lxc-attach android1 20240319110136.564 ERROR attach - attach.c:lxc_attach_run_shell:1503 - No such file or directory - Failed to execute shell
即lxc/attach.c中的lxc_attach_run_shell方法,此方法作为参数传给lxccontainer.c的attach方法指针,也就是lxcapi_attach方法。
lxcapi_attach
→lxc_attach
→→
原因排查:
通过nsenter命令进入容器命名空间,发现执行/system/bin/sh也是报no such file错误。怀疑是链接器找不到的问题
果然which linker没有返回结果,且/apex目录为空。
查看内核日志:
Command 'exec_start apexd-bootstrap' action=early-init (/init.rc:39) took 15ms and failed: Could not start exec service: File /system/bin/apexd(labeled "u:object_r:media_rw_data_file:s0") has incorrect label or no domain transition from u:r:init:s0 to another SELinux domain defined. Have you configured your service correctly? https://source.android.com/security/selinux/device-policy#label_new_services_and_address_denials
应该是恢复recovery导致了问题.
解决办法:
重新编译解决了label问题的second init作为容器的启动init
0 条评论