Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: All /proc/*/exe became /apex/com.android.runtime/bin/linker64 cause oh my tmux break after tmux 3.5 released #149

Closed
fornwall opened this issue Oct 7, 2024 · 7 comments · Fixed by termux-play-store/termux-exec#6

Comments

@fornwall
Copy link
Contributor

fornwall commented Oct 7, 2024

Migrated from termux/termux-app#4188, as this issue is specific to the Play Store distribution of Termux.

Problem description

Recently tmux released 3.5 and oh my tmux broken.

gpakosz/.tmux#761

After some patches it's worked on my pc, but not my android.

gpakosz/.tmux#765

Our investigation found this and may need your help.
gpakosz/.tmux#765 (comment)

Steps to reproduce the behavior.

  • install tmux & oh my tmux
  • run tmux new
    And then we noticed that oh my tmux is not working.

What is the expected behavior?

oh my tmux theme should working fine.

System information

  • Termux application version: Termux googleplay.2024.08.29

  • Android OS version:Android REL 12 aarch64

  • Device model: Xiaomi Redmi K30 5G

fastfetch output:

u0_a767@localhost
-----------------
OS: Android REL 12 aarch64
Host: Xiaomi Redmi K30 5G
Kernel: Linux 4.19.113-perf-ga1b60ef832fb
Uptime: 5 days, 18 hours, 54 mins
Packages: 132 (dpkg)
Shell: fish 3.7.1
WM: Window Manager
Terminal: Termux googleplay.2024.08.29
CPU: SM7250 (8) @ 2.40 GHz
Memory: 4.19 GiB / 7.25 GiB (58%)
Swap: 2.16 GiB / 6.00 GiB (36%)
Disk (/): 2.75 GiB / 3.01 GiB (91%) - ext4 [Read-only]
Disk (/storage/emulated): 77.97 GiB / 107.04 GiB (73%) - fuse
Local IP (tun0): 172.19.0.1/30
Local IP (wlan0): 192.168.123.5/24
Locale: en_US.UTF-8
@gpakosz
Copy link

gpakosz commented Oct 7, 2024

The issue is that Oh my tmux! tries to locate the tmux executable on the filesystem.

It does so by issuing a call to readink /proc/$(tmux display -p '#{pid}')/exe and the output is /apex/com.android.runtime/bin/linker64 instead of /data/data/com.termux/files/usr/bin/tmux.

@fornwall
Copy link
Contributor Author

fornwall commented Oct 7, 2024

@gpakosz @XyLyXyRR This issue is an unfortunate consequence of Android preventing executing files not part of the APK - see https://github.com/termux-play-store/termux-exec?tab=readme-ov-file#problem-1-cannot-execute-files-not-part-of-the-apk for details.

In short, Termux on Google Play is not allowed to execute /data/data/com.termux/files/usr/bin/tmux directly, instead it executes /apex/com.android.runtime/bin/linker64 /data/data/com.termux/files/usr/bin/tmux, leading to reading the exe symlink under /proc not working as expected.

Termux on F-Droid avoids that for now by running in a backward compatibility mode by having a low targetSdkVersion - but support for that is being phased out in general, and it's not allowed when distributing apps on Google Play.

If possible, I think the best workaround here is if you could fall back to looking up tmux in the PATH by using which or command.

@gpakosz
Copy link

gpakosz commented Oct 7, 2024

Interesting,

Based on this comment, this doesn't seem to apply to /proc/self/exe though?

@fornwall
Copy link
Contributor Author

fornwall commented Oct 7, 2024

Based on gpakosz/.tmux#765 (comment), this doesn't seem to apply to /proc/self/exe though?

Due to how often checking /proc/self/exe is done, readlink(3) is hooked using LD_PRELOAD to override when /proc/self/exe is resolved.

It could perhaps be done for /proc/${PID}/exe as well, to make things work more out of the box.. Let me try it out.

@fornwall
Copy link
Contributor Author

fornwall commented Oct 7, 2024

This should be fixed in version 1.7 of the termux-exec package (it hooks readlink(3) of /proc/$PID/exe using LD_PRELOAD, so it should work as expected).

@XyLyXyRR Could you update with pkg up and verify that it works as expected on your device?

@XyLyXyRR
Copy link

XyLyXyRR commented Oct 8, 2024

Seems fixed right now.

env | rg TMUX returns nothing, tmux is 3.5a, oh my tmux is 2c9ef1c, and run tmux new works fine.

Now sudo eza -la /proc/*/exe returns this:

lrwxrwxrwx - u0_a767  8 Oct 08:03 /proc/9073/exe -> /data/data/com.termux/files/usr/bin/fish
lrwxrwxrwx - u0_a767  8 Oct 08:03 /proc/9812/exe -> /data/data/com.termux/files/usr/bin/tmux
lrwxrwxrwx - u0_a767  8 Oct 08:03 /proc/9814/exe -> /data/data/com.termux/files/usr/bin/tmux
lrwxrwxrwx - u0_a767  8 Oct 08:03 /proc/10053/exe -> /data/data/com.termux/files/usr/bin/fish
lrwxrwxrwx - root     8 Oct 08:04 /proc/self/exe -> /data/data/com.termux/files/usr/bin/eza
lrwxrwxrwx - root     8 Oct 08:04 /proc/thread-self/exe -> /data/data/com.termux/files/usr/bin/eza

Thank you. Have a good day, guys!

@gpakosz
Copy link

gpakosz commented Oct 8, 2024

Thank you @fornwall 🙏

gpakosz added a commit to gpakosz/.tmux that referenced this issue Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants