termux / proot-distro

An utility for managing installations of the Linux distributions in Termux.
GNU General Public License v3.0
1.8k stars 208 forks source link

[Bug]: termux-x11 exits instantly, silently and with 0 exit code #333

Closed drjaska closed 1 year ago

drjaska commented 1 year ago

Problem description

Attempting to run a termux-11 server in proot-distro doesn't provide any x11 server but exits instantly, without any stdout nor stderr prints and with 0 for its exit code.

┌[@localhost]
└[0] ~ > proot-distro login debian --shared-tmp --user drjaska
┌[drjaska@localhost]
└[0] ~ > termux-x11 :1 -xstartup "xclock"
┌[drjaska@localhost]
└[0] ~ >

twaik: Possibly proot-distro does not bind some android pathes needed by app_process, you should open issue in proot-distro's repo.

What steps will reproduce the bug?

I don't know if the issue is reproducible with these but these were my steps:

doesn't exit instantly and provides connectable x11 server with the termux:x11 mobile app

these exit instantly, without any stdout nor stderr prints and with 0 exit code

What is the expected behavior?

termux-x11 :1 -xstartup "xclock" should not exit instantly and should provide a x11 server instead of exiting instantly.

Bug report policy acknowledgement

sylirre commented 1 year ago

Try starting termux-x11 again and immediately capture logcat output. Post the output here.

drjaska commented 1 year ago

I ran the termux-x11 :1 -xstartup "xclock" command a few times in proot-distro and adb log section for kinda that timeframe looks like this

Click to expand ``` 08-25 02:20:05.971 2677 2685 I native : I0000 00:00:1692919205.971392 2685 tf_lite_classifier.cc:400] Event stream classified as kNone 08-25 02:20:05.991 26403 26403 W proot : type=1400 audit(0.0:306807): avc: granted { execute } for name="termux-x11" dev="dm-41" ino=1984105 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:05.991 26403 26403 W proot : type=1400 audit(0.0:306808): avc: granted { execute } for name="dash" dev="dm-41" ino=1157812 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:05.991 26403 26403 W proot : type=1400 audit(0.0:306809): avc: granted { execute } for name="dash" dev="dm-41" ino=1157812 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:05.991 26675 26675 W zsh : type=1400 audit(0.0:306810): avc: granted { execute } for name="loader" dev="dm-41" ino=3108417 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:05.991 26675 26675 W zsh : type=1400 audit(0.0:306811): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/libexec/proot/loader" dev="dm-41" ino=3108417 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:06.167 26675 26675 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 1000 <<<<<< 08-25 02:20:06.824 2677 2685 I native : I0000 00:00:1692919206.823965 2685 tf_lite_classifier.cc:400] Event stream classified as kNone 08-25 02:20:07.006 1414 19182 I QC2Comp : [avcD_2501] Stats: Works: Q(26654)/Done(26648)| Work-Rate: Q(0.0/s Avg=9.1/s) Done(0.000/s Avg=9.129/s)| Stream: 59.94fps 4.6Mbps| Pending(6) i/p-done(2) 08-25 02:20:07.428 2677 2685 I native : I0000 00:00:1692919207.428009 2685 tf_lite_classifier.cc:400] Event stream classified as kNone 08-25 02:20:07.447 26403 26403 W proot : type=1400 audit(0.0:306840): avc: granted { execute } for name="termux-x11" dev="dm-41" ino=1984105 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:07.447 26403 26403 W proot : type=1400 audit(0.0:306841): avc: granted { execute } for name="dash" dev="dm-41" ino=1157812 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:07.447 26403 26403 W proot : type=1400 audit(0.0:306842): avc: granted { execute } for name="dash" dev="dm-41" ino=1157812 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:07.447 26698 26698 W zsh : type=1400 audit(0.0:306843): avc: granted { execute } for name="loader" dev="dm-41" ino=3108417 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:07.447 26698 26698 W zsh : type=1400 audit(0.0:306844): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/libexec/proot/loader" dev="dm-41" ino=3108417 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:07.605 26698 26698 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 1000 <<<<<< 08-25 02:20:07.613 1894 2744 D ConnectivityService: NetReassign [no changes] [c 1] [a 1] [i 1] 08-25 02:20:07.950 1395 1488 D VSC : @ 1421771.265: [WO] Proposed rotation: 3, flat angle threshold: 40 08-25 02:20:07.950 1395 1488 D VSC : @ 1421771.265: [WO] orientation angle 274, orientation 3 08-25 02:20:07.950 1395 1488 D VSC : @ 1421771.265: [WO] Gyro angle integrated: 0.155742 08-25 02:20:08.366 1395 1488 D VSC : @ 1421771.682: [Significant Motion] Request motion_detect, interval 18446744027136.0 ms, latency 0.0 ms 08-25 02:20:08.366 1395 1488 D VSC : @ 1421771.683: [Significant Motion] Stop accel 08-25 02:20:08.368 1395 1488 D ASH : @ 1421771.685: SensorType 195 resampler quality 2 08-25 02:20:08.389 2677 2685 I native : I0000 00:00:1692919208.389084 2685 tf_lite_classifier.cc:400] Event stream classified as kNone 08-25 02:20:08.963 2677 2685 I native : I0000 00:00:1692919208.963733 2685 tf_lite_classifier.cc:400] Event stream classified as kNone 08-25 02:20:08.977 26403 26403 W proot : type=1400 audit(0.0:306873): avc: granted { execute } for name="termux-x11" dev="dm-41" ino=1984105 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:08.977 26403 26403 W proot : type=1400 audit(0.0:306874): avc: granted { execute } for name="dash" dev="dm-41" ino=1157812 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:08.977 26403 26403 W proot : type=1400 audit(0.0:306875): avc: granted { execute } for name="dash" dev="dm-41" ino=1157812 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:08.977 26721 26721 W zsh : type=1400 audit(0.0:306876): avc: granted { execute } for name="loader" dev="dm-41" ino=3108417 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:08.977 26721 26721 W zsh : type=1400 audit(0.0:306877): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/libexec/proot/loader" dev="dm-41" ino=3108417 scontext=u:r:untrusted_app_27:s0:c150,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c150,c257,c512,c768 tclass=file app=com.termux.widget 08-25 02:20:09.190 1414 19186 W C2BqBuffer: last successful dequeue was 1715780486 us ago, 152696 consecutive failures 08-25 02:20:09.208 26721 26721 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 1000 <<<<<< ```
sylirre commented 1 year ago

I need the complete log

sylirre commented 1 year ago

And try to not start PRoot Distro from Termux:Widget. Just open Termux, start PRoot Distro and then termux-x11.

sylirre commented 1 year ago

I can't find anything related in your log and can't reproduce the issue on my own:

screen

I suggest few more things for troubleshooting:

drjaska commented 1 year ago

Ah, it works in bash but not in zsh. Try changing your login shell from bash to any other shell with for example install zsh and run chsh -s $(which zsh) and log out and back in.

I looked at the env vars I had with bash and with zsh and found these notable differences.

< SHELL : '/usr/bin/bash'
> SHELL : '/usr/bin/zsh'
< ANDROID_ART_ROOT : '/apex/com.android.art'
> ANDROID_ART_ROOT : ''
< ANDROID_DATA : '/data'
> ANDROID_DATA : ''
< ANDROID_I18N_ROOT : '/apex/com.android.i18n'
> ANDROID_I18N_ROOT : ''
< ANDROID_ROOT : '/system'
> ANDROID_ROOT : ''
< ANDROID_TZDATA_ROOT : '/apex/com.android.tzdata'
> ANDROID_TZDATA_ROOT : ''
< LANG : 'C.UTF-8'
> LANG : ''
< MOZ_FAKE_NO_SANDBOX : '1'
> MOZ_FAKE_NO_SANDBOX : ''
< BOOTCLASSPATH : '/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/framework-graphics.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/apex/com.android.i18n/javalib/core-icu4j.jar:/apex/com.android.adservices/javalib/framework-adservices.jar:/apex/com.android.adservices/javalib/framework-sdksandbox.jar:/apex/com.android.appsearch/javalib/framework-appsearch.jar:/apex/com.android.btservices/javalib/framework-bluetooth.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.ipsec/javalib/android.net.ipsec.ike.jar:/apex/com.android.media/javalib/updatable-media.jar:/apex/com.android.mediaprovider/javalib/framework-mediaprovider.jar:/apex/com.android.ondevicepersonalization/javalib/framework-ondevicepersonalization.jar:/apex/com.android.os.statsd/javalib/framework-statsd.jar:/apex/com.android.permission/javalib/framework-permission.jar:/apex/com.android.permission/javalib/framework-permission-s.jar:/apex/com.android.scheduling/javalib/framework-scheduling.jar:/apex/com.android.sdkext/javalib/framework-sdkextensions.jar:/apex/com.android.tethering/javalib/framework-connectivity.jar:/apex/com.android.tethering/javalib/framework-connectivity-t.jar:/apex/com.android.tethering/javalib/framework-tethering.jar:/apex/com.android.uwb/javalib/framework-uwb.jar:/apex/com.android.wifi/javalib/framework-wifi.jar'
> BOOTCLASSPATH : ''
< COLORTERM : 'truecolor'
> COLORTERM : ''
< PULSE_SERVER : '127.0.0.1'
> PULSE_SERVER : ''
< DEX2OATBOOTCLASSPATH : '/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/framework-graphics.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/apex/com.android.i18n/javalib/core-icu4j.jar'
> DEX2OATBOOTCLASSPATH : ''
< EXTERNAL_STORAGE : '/sdcard'
> EXTERNAL_STORAGE : ''
< TMPDIR : '/tmp'
> TMPDIR : ''

Running the following command works in zsh and does provide an usable Xorg server I think.

ANDROID_ART_ROOT="/apex/com.android.art" ANDROID_DATA="/data" ANDROID_I18N_ROOT="/apex/com.android.i18n" ANDROID_ROOT="/system" ANDROID_TZDATA_ROOT="/apex/com.android.tzdata" LANG="C.UTF-8" MOZ_FAKE_NO_SANDBOX="1" BOOTCLASSPATH="/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/framework-graphics.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/apex/com.android.i18n/javalib/core-icu4j.jar:/apex/com.android.adservices/javalib/framework-adservices.jar:/apex/com.android.adservices/javalib/framework-sdksandbox.jar:/apex/com.android.appsearch/javalib/framework-appsearch.jar:/apex/com.android.btservices/javalib/framework-bluetooth.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.ipsec/javalib/android.net.ipsec.ike.jar:/apex/com.android.media/javalib/updatable-media.jar:/apex/com.android.mediaprovider/javalib/framework-mediaprovider.jar:/apex/com.android.ondevicepersonalization/javalib/framework-ondevicepersonalization.jar:/apex/com.android.os.statsd/javalib/framework-statsd.jar:/apex/com.android.permission/javalib/framework-permission.jar:/apex/com.android.permission/javalib/framework-permission-s.jar:/apex/com.android.scheduling/javalib/framework-scheduling.jar:/apex/com.android.sdkext/javalib/framework-sdkextensions.jar:/apex/com.android.tethering/javalib/framework-connectivity.jar:/apex/com.android.tethering/javalib/framework-connectivity-t.jar:/apex/com.android.tethering/javalib/framework-tethering.jar:/apex/com.android.uwb/javalib/framework-uwb.jar:/apex/com.android.wifi/javalib/framework-wifi.jar" COLORTERM="truecolor" PULSE_SERVER="127.0.0.1" DEX2OATBOOTCLASSPATH="/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/framework-graphics.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/apex/com.android.i18n/javalib/core-icu4j.jar" SHELL="/usr/bin/bash" EXTERNAL_STORAGE="/sdcard" TMPDIR="/tmp" termux-x11 :1 -xstartup "xclock"
drjaska commented 1 year ago

Pasting those env vars to /etc/environment is a working band-aid fix too.

sylirre commented 1 year ago

Yes, /etc/environment seems to work. Need to do some testing to see whether using this file is reliable enough to replace /etc/profile.d across different distributions.

As far I know /etc/environment is loaded by PAM, but not all distributions use PAM for su and login utilities.

BBCByComcast commented 1 year ago

Syliree, Can You Ask?

sylirre commented 1 year ago

Fixed in the latest git.