termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
745 stars 161 forks source link

proot error: '/system/bin/toolbox' is a 64-bit program whereas this version of proot handles 32-bit programs only #197

Closed GJoe2 closed 2 years ago

GJoe2 commented 2 years ago

Problem description

Toolbox cant be executed due to proot being 32 bits, similar issues with other custom distros (i.e. https://github.com/Hax4us/TermuxAlpine https://github.com/TermuxArch/TermuxArch) image

CPU and ABI seems to be 64 bits (aarch64 - arm64-v8a), I only suspect the OS version could be 32 bits, but Im not sure how to know that, if my OS is 32 bits I would like to know how to get a proot x64 so toolbox works and proot custom distros works so.

Steps to reproduce

install proot execute toolbox inside proot

Expected behavior

toolbox works

Additional information

$ uname -a
Linux localhost 4.14.113-22145712 #1 SMP PREEMPT Sat Jul 31 05:45:23 KST 2021 armv8l Android

$ getprop | grep cpu
[ro.odm.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist64]: [arm64-v8a]
[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [arm64-v8a]
[ro.vendor.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist64]: [arm64-v8a]

$ file /system/lib64/
/system/lib64/: directory

more information:

<<< System >>>

Model: SM-A515F Board: exynos9611

<<< CPU >>>

Scaling Governor: schedutil Supported ABIs: arm64-v8a, armeabi-v7a, armeabi Supported 32-bit ABIs: armeabi-v7a, armeabi Supported 64-bit ABIs: arm64-v8a

<<< Android >>>

Android Version: 11 API Level: 30 Kernel Architecture: aarch64 Kernel Version: 4.14.113-22145712

Aditionally I would like to know why uname -m output armv8l instead of aarch64, using other terminals apps like pydroid give me this result:

/storage/emulated/0 $ uname -m
aarch64

Alternative Using TermOne Plus -terminal emulator (https://gitlab.com/termapps/termoneplus)

:/ $ uname -m
aarch64

EDIT 1:

$ getprop | grep -e 32 -e 64
[dalvik.vm.dex2oat-Xms]: [64m]
[dalvik.vm.image-dex2oat-Xms]: [64m]
[dalvik.vm.image-dex2oat-Xmx]: [64m]
[dalvik.vm.isa.arm64.features]: [default]
[dalvik.vm.isa.arm64.variant]: [generic]
[gsm.nitz.time]: [1634452646000]
[init.svc.boringssl_self_test32]: [stopped]
[init.svc.boringssl_self_test32_vendor]: [stopped]
[init.svc.boringssl_self_test64]: [stopped]
[init.svc.boringssl_self_test64_vendor]: [stopped]
[init.svc.boringssl_self_test_apex32]: [stopped]
[init.svc.boringssl_self_test_apex64]: [stopped]
[init.svc.snap_utility_64]: [stopped]
[ro.boot.im.param.offset]: [7342864]
[ro.logd.size.stats]: [64K]
[ro.odm.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist64]: [arm64-v8a]
[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [arm64-v8a]
[ro.vendor.boot.im.param.offset]: [7342864]
[ro.vendor.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist64]: [arm64-v8a]
[ro.zygote]: [zygote64_32]
[sys.usb.controller]: [13200000.dwc3]
[vendor.sec.rild.libpath]: [/vendor/lib64/libsec-ril.so]
[vendor.sec.rild.libpath2]: [/vendor/lib64/libsec-ril-dsds.so]
$ termux-info
Application version:
0.117
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://packages.termux.org/apt/termux-main/ stable main
# game-repo (sources.list.d/game.list)
deb https://packages.termux.org/apt/termux-games games stable
# science-repo (sources.list.d/science.list)
deb https://packages.termux.org/apt/termux-science science stable
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.org/apt/termux-x11 x11 main
# unstable-repo (sources.list.d/unstable.list)
deb https://packages.termux.org/apt/termux-unstable unstable main
Updatable packages:
libicu/stable 69.1-1 arm [upgradable from: 69.1]
Android version:
11
Kernel build information:
Linux localhost 4.14.113-22145712 #1 SMP PREEMPT Sat Jul 31 05:45:23 KST 2021 armv8l Android
Device manufacturer:
samsung
Device model:
SM-A515F
$ proot --verbose=2
proot info: binding = /
proot info: vpid 1: translate("/" + "/bin/sh")
proot info: vpid 1:          -> "/system/bin/sh"
proot info: vpid 1: translate("/" + "/bin/sh")
proot info: vpid 1:          -> "/system/bin/sh"
proot info: exe = /system/bin/sh
proot info: argv =
proot info: initial cwd = /data/data/com.termux/files/home/rdfiles
proot info: verbose level = 2
proot info: pid 29301: access to "/dev/pts/1" (fd 0) won't be translated until closed
proot info: pid 29301: access to "/dev/pts/1" (fd 1) won't be translated until closed
proot info: pid 29301: access to "/dev/pts/1" (fd 2) won't be translated until closed
proot info: pid 29301: access to "/proc/29301/fd" (fd 3) won't be translated until closed
proot info: vpid 1: translate("/" + "/system/bin/sh")
proot info: vpid 1:          -> "/system/bin/sh"
proot info: ptrace acceleration (seccomp mode 2, new syscall order) enabled
proot info: vpid 1: translate("/" + "/system/bin/sh")
proot info: vpid 1:          -> "/system/bin/sh"
proot info: vpid 1: translate("/" + "/system/bin/sh")
proot info: vpid 1:          -> "/system/bin/sh"
proot info: vpid 1: translate("/" + "/system/bin/linker64")
proot info: vpid 1:          -> "/apex/com.android.runtime/bin/linker64"
proot error: execve("/system/bin/sh"): Bad address
proot info: possible causes:
  * the program is a script but its interpreter (eg. /bin/sh) was not found;
  * the program is an ELF but its interpreter (eg. ld-linux.so) was not found;
  * the program is a foreign binary but qemu was not specified;
  * qemu does not work correctly (if specified);
  * the loader was not found or doesn't work.
fatal error: see `proot --help`.
proot info: vpid 1: exited with status 1
Yonle commented 2 years ago

Your last uname -a just shows that your phone is using 64 bit CPU, But your Operating System is in 32 bit instead of 64 bit.

Yonle commented 2 years ago

I can also say that the main problem is at your operating system which is using 32 bit Binaries instead of what you want.

You may use something like qemu-user-aarch64. You may contact to Manufacter regarding this issue.

ghost commented 2 years ago

@Yonle No, this is normal 64 bit Android OS. Please read the issue carefully, especially stats:

[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [arm64-v8a]

Btw, nothing to do with Termux either. That's entirely setup issue.

ghost commented 2 years ago

@Gurren-Joestar You have installed 32 bit variant of Arch Linux, that's why the issue happens. Install 64 bit and error will gone.

ghost commented 2 years ago

You may try proot-distro for setting up Arch or other distributions under proot. Also check the return value of dpkg --print-architecture and make sure it is aarch64. If there is returned arm or something like, then you may need to completely re-install Termux (https://f-droid.org/repo/com.termux_117.apk).

GJoe2 commented 2 years ago
$ dpkg --print-architecture
arm
SDRausty commented 2 years ago

installed 32 bit variant of Arch Linux

Was this the key line? proot error: execve("/system/bin/sh"): Bad address If so, please explain how.

I studied the output and still cannot phantom how you knew this is a NOT a mixed architecture issue.

ghost commented 2 years ago

I studied the output and still cannot phantom how you knew this is a NOT a mixed architecture issue.

Do not read between lines. In my first comment there is no statement that this is not mixed architecture issue.

This is a standard 64 bit installation of Android OS (see ABIs in stats), but Termux environment is somehow 32bit. The only ways how this is possible are:

GJoe2 commented 2 years ago

Edit 2 : I installed first Termux in a old device (Samsung j7 prime - arm32 bits), make the back up (with google play version), later I bought a new device which is the currently Im using, I remeber I tried to use the old backups on my new device (arm64 with fdroid) but cant tell or remember if it works or not

ghost commented 2 years ago

32 bit backup won't automatically become 64 bit. If you really restored Termux from made backup, this falls under case

  • Custom bootstrap installation
SDRausty commented 2 years ago

accidentally pick armeabi-v7a build instead of armv8-a or universal

I have not tried the debug builds yet; You can choose the architecture download at https://github.com/termux/termux-app/actions/workflows/debug_build.yml

GJoe2 commented 2 years ago

If there is returned arm or something like, then you may need to completely re-install Termux

$ uname -m
aarch64

Thanks, reinstalling Termux was the solution for proot issue and Termux architecture version