termux-app icon indicating copy to clipboard operation
termux-app copied to clipboard

[Bug]: dpkg: error processing package ffmpeg (--configure)

Open PorkPieHat opened this issue 3 weeks ago • 12 comments

Problem description

I recently updated termux to v0.118.3 using this guide;

https://github.com/termux/termux-app#installation

I backed--up and restored my previous (very old) version of termux as directed here:

https://wiki.termux.com/wiki/Backing_up_Termux

My first update after installing the new termux ran to 173 packages.

The update ran mostly OK, but I ran into an issue updating ffmpeg

Steps to reproduce the behavior.

~ $ pkg update

~ $ apt list --upgradable
<others>
dpkg/stable 1.22.6-5 aarch64 [upgradable from: 1.21.22]
ed/stable 1.22.3 aarch64 [upgradable from: 1.19]
ffmpeg/stable 8.0.1 aarch64 [upgradable from: 6.0-5]    <----------
fftw/stable 3.3.10-4 aarch64 [upgradable from: 3.3.10-3]
findutils/stable 4.10.0-1 aarch64 [upgradable from: 4.9.0-2]
<and others>

~ $ pkg upgrade

Ends...

Setting up pango (1.57.0) ... 
Setting up libass (0.17.4-1) ...
Setting up ffmpeg (8.0.1) ... 
Segmentation fault (core dumped)
WARNING: linker: /data/data/com.termux/files/usr/lib/libandroid.so: unused DT entry: type 0x6fffe000 arg 0x3788
WARNING: linker: /data/data/com.termux/files/usr/lib/libandroid.so: unused DT entry: type 0x6fffe001 arg 0x10                              WARNING: linker: /data/data/com.termux/files/usr/lib/libandroid.so: unused DT entry: type 0x6fffe003 arg 0x8
WARNING: linker: /data/data/com.termux/files/usr/lib/libmediandk.so: unused DT entry: type 0x6fffe000 arg 0x25f8
WARNING: linker: /data/data/com.termux/files/usr/lib/libmediandk.so: unused DT entry: type 0x6fffe001 arg 0x10                                   WARNING: linker: /data/data/com.termux/files/usr/lib/libmediandk.so: unused DT entry: type 0x6fffe003 arg 0x8
WARNING: linker: /data/data/com.termux/files/usr/lib/libandroid.so: unused DT entry: type 0x6fffe000 arg 0x3788
WARNING: linker: /data/data/com.termux/files/usr/lib/libandroid.so: unused DT entry: type 0x6fffe001 arg 0x10                                   WARNING: linker: /data/data/com.termux/files/usr/lib/libandroid.so: unused DT entry: type 0x6fffe003 arg 0x8
Failed to run the 'ffmpeg' command.dpkg: error processing package ffmpeg (--configure):
installed ffmpeg package post-installation script subprocess returned error exit status 1
Setting up librsvg (2.61.3) ...
Setting up imlib2 (1.12.5-1) ...
Setting up libcaca (0.99.beta20-3) ...
dpkg: dependency problems prevent configuration of mpv:
mpv depends on ffmpeg; however:
Package ffmpeg is not configured yet.
dpkg: error processing package mpv (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
ffmpeg
mpv
E: Sub-process /data/data/com.termux/files/usr/bin/dpkg returned an error code (1)
~ $

What is the expected behavior?

The expected behaviour was that ffmpeg would update without issues

Tried

~ $ apt purge ffmpeg

Followed by:

~ $ apt install ffmpeg

Same result

System information

  • Termux application version: 0.118.3
  • Android OS version: 7.1.1
  • Device model: Sony Xperia Z5, model E5823

PorkPieHat avatar Dec 01 '25 14:12 PorkPieHat

Could you use this command and show the result?

apt-cache policy libandroid-stub

also, please use this command and show the result:

termux-info

robertkirkman avatar Dec 01 '25 14:12 robertkirkman

It is a recently-introduced bug that can be bisected, I will try to find a workaround. I can reproduce it.

@PorkPieHat while you wait for a solution, you can use ffmpeg7 package from TUR if you want, which is unaffected:

pkg install tur-repo
pkg install ffmpeg7
ffmpeg7

robertkirkman avatar Dec 01 '25 15:12 robertkirkman

It is a recently-introduced bug that can be bisected, I will try to find a workaround. I can reproduce it.

Where does that bisect to exactly? Did it start happening with ffmpeg 8.0 or what?

TomJo2000 avatar Dec 01 '25 15:12 TomJo2000

It is a recently-introduced bug that can be bisected, I will try to find a workaround. I can reproduce it.

Where does that bisect to exactly? Did it start happening with ffmpeg 8.0 or what?

no probably not. right now I am checking the behavior of FFmpeg + all dependencies built entirely with NDK r28c instead of NDK r29 (using this commit https://github.com/termux/termux-packages/commit/2de2878d08bd90ec345d1d37b61f79885cf16c4d + docker build -t ghcr.io/termux/package-builder scripts/ etc.)

robertkirkman avatar Dec 01 '25 15:12 robertkirkman

@twaik unfortunately, NDK r29 has broken the libandroid-stub :(

Problem bisection commit in Termux: https://github.com/termux/termux-packages/commit/bd8b24b00afd94c7c33922bc5421159f59edff9e

Problem bisection commit in upstream: suspected to be in LLVM project, somewhere in between Clang 19 and Clang 21

(it could be in the Android-specific portion of NDK, but I suspect the change is more likely to be in an LLVM commit because of some evidence I noticed that is hard to explain, I could explain further if necessary)

Problem not reproducible on:

  • Samsung Galaxy S8+ SM-G955F Android 14 aarch64
  • Samsung Galaxy A70 SM-A705FN Android 13 aarch64
  • Samsung Galaxy S9 SM-G960U Android 10 aarch64

Problem reproducible on:

  • Samsung Galaxy S7 SM-G930U Android 8.0.0 aarch64
  • Samsung Galaxy S III SPH-L710 Android 7.1.2 armv7l
  • Sony Xperia Z5 E5823 Android 7.1.1 aarch64 (issue reporter device)

I can try to figure out how to fix it, but if I can't understand how, I have determined it would be possible to fix the problem as a last resort by building libandroid-stub with its own dedicated NDK version (similar to for example package aosp-libs).

I checked and rebuilding libandroid-stub with NDK r28c again makes the problem stop and then upgrading libandroid-stub makes the error come back.

robertkirkman avatar Dec 01 '25 16:12 robertkirkman

Backtrace, with libandroid-stub built like this:

--- a/packages/libandroid-stub/build.sh
+++ b/packages/libandroid-stub/build.sh
@@ -13,7 +13,7 @@ TERMUX_PKG_SKIP_SRC_EXTRACT=true
 TERMUX_PKG_API_LEVEL=28
 
 termux_step_make() {
-       "${CC}" -shared -fPIC -o "${TERMUX_PREFIX}/lib/libandroid.so" "$TERMUX_PKG_BUILDER_DIR/libandroid-wrapper.c" -Wno-deprecated-declarations
-       "${CC}" -shared -fPIC -o "${TERMUX_PREFIX}/lib/libmediandk.so" "$TERMUX_PKG_BUILDER_DIR/libmediandk-wrapper.c" -Wno-deprecated-declarations
-       "${CC}" -shared -fPIC -o "${TERMUX_PREFIX}/lib/libOpenSLES.so" "$TERMUX_PKG_BUILDER_DIR/libOpenSLES-wrapper.c" -Wno-deprecated-declarations
+       "${CC}" -g -O0 -shared -fPIC -o "${TERMUX_PREFIX}/lib/libandroid.so" "$TERMUX_PKG_BUILDER_DIR/libandroid-wrapper.c" -Wno-deprecated-declarations
+       "${CC}" -g -O0 -shared -fPIC -o "${TERMUX_PREFIX}/lib/libmediandk.so" "$TERMUX_PKG_BUILDER_DIR/libmediandk-wrapper.c" -Wno-deprecated-declarations
+       "${CC}" -g -O0 -shared -fPIC -o "${TERMUX_PREFIX}/lib/libOpenSLES.so" "$TERMUX_PKG_BUILDER_DIR/libOpenSLES-wrapper.c" -Wno-deprecated-declarations
 }
(gdb) bt
#0  0x0000000000007a40 in ?? ()
#1  0x0000007fb7ec2450 in __dl__ZL10call_arrayIPFviPPcS1_EEvPKcPT_mbS5_ () from /system/bin/linker64
#2  0x0000007fb7ec2680 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#3  0x0000007fb7ec2578 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#4  0x0000007fb7ec2578 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#5  0x0000007fb7ec2578 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#6  0x0000007fb7ec2578 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#7  0x0000007fb7ec2578 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#8  0x0000007fb7ebe688 in __dl___linker_init () from /system/bin/linker64
#9  0x0000007fb7ec49c4 in __dl__start () from /system/bin/linker64
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) quit
A debugging session is active.

	Inferior 1 [process 20074] will be killed.

Quit anyway? (y or n) y
~/termux-packages $ file $PREFIX/lib/libandroid.so
/data/data/com.termux/files/usr/lib/libandroid.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, for Android 24, built by NDK r29 (14206865), with debug_info, not stripped
~/termux-packages $ 

robertkirkman avatar Dec 01 '25 16:12 robertkirkman

Thanks for the prompt responses.

Replying to Robert Kirkman's first post:

Could you use this command and show the result?

apt-cache policy libandroid-stub

also, please use this command and show the result:

termux-info
~ $ apt-cache policy libandroid-stub
libandroid-stub:
  Installed: 29
  Candidate: 29
  Version table:
 *** 29 500
        500 https://packages-cf.termux.dev/apt/termux-main stable/main aarch64 Packages
        100 /data/data/com.termux/files/usr/var/lib/dpkg/status
~ $

And:

~ $ termux-info
Termux Variables:
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=25145
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__LEGACY_DATA_DIR=/data/data/com.termux
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c512,c768
TERMUX_APP__SE_INFO=default
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.3
TERMUX__HOME=/data/data/com.termux/files/home
TERMUX__PREFIX=/data/data/com.termux/files/usr
TERMUX__ROOTFS_DIR=/data/data/com.termux/files    TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app:s0:c512,c768
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64                                           Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main/ stable main
Updatable packages:
All packages up to date
termux-tools version:
1.45.0
Android version:
7.1.1
Kernel build information:
Linux localhost 3.10.84-perf-g99119bc #1 SMP PREEMPT Fri Aug 18 15:21:50 2017 aarch64 Android
Device manufacturer:
Sony
Device model:
E5823
Supported ABIs:
SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS: arm64-v8a
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
~ $

Hope this helps

Suggested workaround noted

Thanks again

PorkPieHat avatar Dec 01 '25 17:12 PorkPieHat

I have created a solution that works on my Android 7 and Android 8 devices, please test it if you are able to and let me know if it works for you!

  • https://github.com/termux/termux-packages/pull/27502

robertkirkman avatar Dec 02 '25 06:12 robertkirkman

I have created a solution that works on my Android 7 and Android 8 devices, please test it if you are able to and let me know if it works for you!

Is this the build.sh script that you suggest I run?

TERMUX_PKG_HOMEPAGE=https://android.googlesource.com/platform/frameworks/base/+/main/native/android
TERMUX_PKG_DESCRIPTION="Stub libandroid.so for non-Android certified environment"
TERMUX_PKG_LICENSE="NCSA"
TERMUX_PKG_MAINTAINER="@termux"
# Version should be equal to TERMUX_NDK_{VERSION_NUM,REVISION} in
# scripts/properties.sh
TERMUX_PKG_VERSION=29
TERMUX_PKG_REVISION=1
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_CONFLICTS="libandroid"
TERMUX_PKG_REPLACES="libandroid"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_SKIP_SRC_EXTRACT=true
TERMUX_PKG_API_LEVEL=28

termux_step_make() {
	local stub
	for stub in android mediandk OpenSLES; do
		"${CC}" -shared -fPIC \
			-o "${TERMUX_PREFIX}/lib/lib${stub}.so" \
			"${TERMUX_PKG_BUILDER_DIR}/lib${stub}-wrapper.c" \
			-Wno-deprecated-declarations \
			-Wl,--no-use-android-relr-tags \
			-Wl,--pack-dyn-relocs=android
	done
}

From here:

https://github.com/robertkirkman/termux-packages/blob/libandroid-stub-ndk29/packages/libandroid-stub/build.sh

PorkPieHat avatar Dec 02 '25 15:12 PorkPieHat

@PorkPieHat Actually, I mean to download the GitHub Actions artifact, from here, and install it to test,

Image

Using this method, but on that PR instead of the PR in the video:

https://github.com/user-attachments/assets/0f576782-3689-49f2-80d8-9c1dfe79034b

You need to be logged into GitHub to see the download link in the PR,

if you are able to do that, then you don't need to manually build it.

robertkirkman avatar Dec 03 '25 00:12 robertkirkman

It should now be fixed if you use pkg upgrade.

robertkirkman avatar Dec 03 '25 10:12 robertkirkman

Image Image

Thanks a lot!

PorkPieHat avatar Dec 03 '25 15:12 PorkPieHat