termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.34k stars 3.07k forks source link

[Bug]: the command "firefox -headless" crashes with Segmentation fault #22286

Open robertkirkman opened 5 days ago

robertkirkman commented 5 days ago

Problem description

The command firefox -headless does not work, which indirectly prevents the Node.js Puppeteer Core library that comes from pkg install nodejs && npm install puppeteer-core from working on Termux without having to also install Termux:X11, configure and launch Termux:X11, and configure Firefox for Termux:X11.

Related issue in another repository that could also potentially be helped simultaneously by a solution to this issue: https://github.com/mermaid-js/mermaid-cli/issues/777

If this is fixed then Puppeteer Core can work directly on Termux, in fully headless mode, without having to have any proot or X11, possibly presenting a viable alternative to the preexisting 3rd party solution that was available already, the proot-based method.

I believe the instances of "Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.215055)" in the logs are probably extremely misleading red herrings, because they came from a different area of the code from where the backtrace leads, and after I fixed the crash, they still printed even while the program worked.

backtrace ``` ~ $ gdb --args firefox -headless GNU gdb (GDB) 15.2 Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "aarch64-linux-android". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from firefox... (gdb) run Starting program: /data/data/com.termux/files/usr/bin/firefox -headless [Thread debugging using libthread_db enabled] Using host libthread_db library "/data/data/com.termux/files/usr/lib/libthread_db.so". warning: section .note.gnu.build-id not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .dynsym not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .gnu.version not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .gnu.version_d not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .gnu.hash not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .dynstr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .rela.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .eh_frame_hdr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .eh_frame not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .dynamic not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .got.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .bss not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so warning: section .note.android.ident not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .note.gnu.build-id not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .dynsym not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .gnu.version not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .gnu.version_d not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .gnu.version_r not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .gnu.hash not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .dynstr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .rela.dyn not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .relr.dyn not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .rela.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .rodata not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .eh_frame_hdr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .eh_frame not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .data.rel.ro not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .fini_array not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .dynamic not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .got not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .got.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .data not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .bss not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so warning: section .note.android.ident not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .note.gnu.build-id not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .dynsym not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .gnu.version not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .gnu.version_r not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .gnu.hash not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .dynstr not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .rela.dyn not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .relr.dyn not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .rela.plt not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .rodata not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .eh_frame_hdr not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .eh_frame not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .plt not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .data.rel.ro not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .fini_array not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .dynamic not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .got not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .got.plt not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .data not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .bss not found in .gnu_debugdata for /system/lib64/libnetd_client.so warning: section .note.android.ident not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .note.gnu.build-id not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .dynsym not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .gnu.version not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .gnu.version_r not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .gnu.hash not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .dynstr not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .rela.dyn not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .relr.dyn not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .rela.plt not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .rodata not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .gcc_except_table not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .eh_frame_hdr not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .eh_frame not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .plt not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .data.rel.ro not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .fini_array not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .init_array not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .dynamic not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .got not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .got.plt not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .data not found in .gnu_debugdata for /system/lib64/libc++.so warning: section .bss not found in .gnu_debugdata for /system/lib64/libc++.so [New Thread 0x3391 (LWP 13201)] [Thread 0x3391 (LWP 13201) exited] warning: section .note.android.ident not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .note.gnu.build-id not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .dynsym not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .gnu.version not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .gnu.version_d not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .gnu.version_r not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .gnu.hash not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .dynstr not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .rela.dyn not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .relr.dyn not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .rela.plt not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .rodata not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .eh_frame_hdr not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .eh_frame not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .plt not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .data.rel.ro not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .fini_array not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .init_array not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .dynamic not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .got not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .got.plt not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .data not found in .gnu_debugdata for /system/lib64/liblog.so warning: section .bss not found in .gnu_debugdata for /system/lib64/liblog.so [New Thread 0x3394 (LWP 13204)] *** You are running in headless mode. [New Thread 0x3397 (LWP 13207)] [Detaching after fork from child process 13208] [New Thread 0x3399 (LWP 13209)] [New Thread 0x339a (LWP 13210)] [New Thread 0x339b (LWP 13211)] [New Thread 0x339c (LWP 13212)] [New Thread 0x339d (LWP 13213)] [New Thread 0x339e (LWP 13214)] [New Thread 0x339f (LWP 13215)] [New Thread 0x33a0 (LWP 13216)] [New Thread 0x33a1 (LWP 13217)] [New Thread 0x33a2 (LWP 13218)] [New Thread 0x33a3 (LWP 13219)] [New Thread 0x33a4 (LWP 13220)] [New Thread 0x33a5 (LWP 13221)] [Thread 0x33a5 (LWP 13221) exited] [New Thread 0x33a6 (LWP 13222)] [New Thread 0x33a7 (LWP 13223)] [New Thread 0x33a8 (LWP 13224)] [New Thread 0x33a9 (LWP 13225)] [New Thread 0x33aa (LWP 13226)] [New Thread 0x33ab (LWP 13227)] [New Thread 0x33ac (LWP 13228)] [New Thread 0x33ad (LWP 13229)] [New Thread 0x33ae (LWP 13230)] [New Thread 0x33af (LWP 13231)] [New Thread 0x33b0 (LWP 13232)] [New Thread 0x33b1 (LWP 13233)] [New Thread 0x33b2 (LWP 13234)] [New Thread 0x33b3 (LWP 13235)] [Thread 0x33a7 (LWP 13223) exited] [New Thread 0x33b4 (LWP 13236)] [New Thread 0x33b5 (LWP 13237)] [New Thread 0x33b6 (LWP 13238)] [New Thread 0x33b7 (LWP 13239)] [New Thread 0x33b8 (LWP 13240)] [New Thread 0x33b9 (LWP 13241)] [New Thread 0x33ba (LWP 13242)] [New Thread 0x33bb (LWP 13243)] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=18.4544) [GFX1-]: glxtest: Unable to open a connection to the X server Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=18.4544) |[1][GFX1-]: No GPUs detected via PCI (t=18.4544) [GFX1-]: No GPUs detected via PCI [New Thread 0x33bc (LWP 13244)] [New Thread 0x33bd (LWP 13245)] [New Thread 0x33be (LWP 13246)] [New Thread 0x33bf (LWP 13247)] [New Thread 0x33c0 (LWP 13248)] [New Thread 0x33c1 (LWP 13249)] [New Thread 0x33c2 (LWP 13250)] [New Thread 0x33c3 (LWP 13251)] [New Thread 0x33c4 (LWP 13252)] [New Thread 0x33c5 (LWP 13253)] [New Thread 0x33c6 (LWP 13254)] [New Thread 0x33c7 (LWP 13255)] [New Thread 0x33c8 (LWP 13256)] [New Thread 0x33c9 (LWP 13257)] [New Thread 0x33ca (LWP 13258)] [New Thread 0x33cb (LWP 13259)] [New Thread 0x33cc (LWP 13260)] [New Thread 0x33cd (LWP 13261)] [New Thread 0x33ce (LWP 13262)] [New Thread 0x33cf (LWP 13263)] [Detaching after fork from child process 13264] [New Thread 0x33d4 (LWP 13268)] Thread 1 "firefox" received signal SIGSEGV, Segmentation fault. 0x0000007d23985fd8 in XInternAtoms () from /data/data/com.termux/files/usr/lib/libX11.so (gdb) bt #0 0x0000007d23985fd8 in XInternAtoms () from /data/data/com.termux/files/usr/lib/libX11.so #1 0x0000007d0ccdcc58 in nsXRemoteServer::EnsureAtoms ( this=0xb400007dda853ed0) at /home/builder/.termux-build/firefox/src/toolkit/components/remote/nsXRemoteServer.cpp:150 #2 nsXRemoteServer::XRemoteBaseStartup (this=0xb400007dda853ed0, aAppName=0xb400007dca8434c8 "firefox-default", aProfileName=0xb400007e1a845338 "/data/data/com.termux/files/home/.mozilla/firefox/r8c88s3d.default-default") at /home/builder/.termux-build/firefox/src/toolkit/components/remote/nsXRemoteServer.cpp:60 #3 0x0000007d0ccda7b0 in nsGTKRemoteServer::Startup (this=0x0, aAppName=0x7d0eeeec30 "48\357\a}", aProfileName=0x7 ) at /home/builder/.termux-build/firefox/src/toolkit/components/remote/nsGTKRemoteServer.cpp:39 #4 0x0000007d0ccdb0b0 in nsRemoteService::StartupServer ( this=0xb400007e2a84abc0) at /home/builder/.termux-build/firefox/src/toolkit/components/remote/nsRemoteService.cpp:189 #5 0x0000007d0cef5d9c in XREMain::XRE_mainRun ( this=this@entry=0x7fffffd8b0) at /home/builder/.termux-build/firefox/src/toolkit/xre/nsAppRunner.cpp:5744 #6 0x0000007d0cef66c4 in XREMain::XRE_main ( this=this@entry=0x7fffffd8b0, argc=argc@entry=2, argv=argv@entry=0x7fffffeb88, aConfig=...) at /home/builder/.termux-build/firefox/src/toolkit/xre/nsAppRunner.cpp:6034 #7 0x0000007d0cef6b04 in XRE_main (argc=250539056, argv=0x7, aConfig=...) at /home/builder/.termux-build/firefox/src/toolkit/xre/nsAppRunner.cpp:6106 #8 0x0000005555579f6c in do_main (argc=2, argv=0x7fffffeb88, envp=) at /home/builder/.termux-build/firefox/src/browser/app/nsBrowserApp.cpp:233 #9 main (argc=2, argv=0x7fffffeb88, envp=) at /home/builder/.termux-build/firefox/src/browser/app/nsBrowserApp.cpp:470 (gdb) ```

What steps will reproduce the bug?

pkg install x11-repo
pkg install firefox
firefox -headless

What is the expected behavior?

*** You are running in headless mode.
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.215055) [GFX1-]: glxtest: Unable to open a connection to the X server
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.215055) |[1][GFX1-]: No GPUs detected via PCI
 (t=0.215055) [GFX1-]: No GPUs detected via PCI

Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.215055) |[1][GFX1-]: No GPUs detected via PCI
 (t=0.215055) |[2][GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt (t=0.885055) [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt
console.error: ({})
console.error: ({})
console.error: "update.locale" " file doesn't exist in either the application or GRE directories"
JavaScript error: resource://gre/modules/XPCOMUtils.sys.mjs, line 150: TypeError: Cc[aContract] is undefined

(idles [desired behavior]) (This is an example of the output when it is actually working. Every error/warning in this section is spurious and was not related to the crash, and it works in spite of them)

System information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__APK_FILE=/data/app/~~gVwKanLEt3onhDQBKcUZQA==/com.termux-Jepd-I809CuxEnnuONZ6_Q==/base.apk
TERMUX_APP__APK_RELEASE=F_DROID
TERMUX_APP__APP_VERSION_CODE=1020
TERMUX_APP__APP_VERSION_NAME=0.119.0-beta.1
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__IS_DEBUGGABLE_BUILD=false
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PID=11460
TERMUX_APP__TARGET_SDK=28
TERMUX_VERSION=0.119.0-beta.1
TERMUX__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c237,c256,c512,c768
TERMUX__SE_INFO=default:targetSdkVersion=28:complete
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c237,c256,c512,c768
TERMUX__UID=10237
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.aliyun.com/termux/termux-main stable main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# sources.list.d/termux-adb.list
deb https://nohajc.github.io termux extras
# x11-repo (sources.list.d/x11.list)
deb https://mirrors.aliyun.com/termux/termux-x11 x11 main
Updatable packages:
firefox/x11 131.0.3-1 aarch64 [upgradable from: 131.0.3-1]
termux-tools version:
1.44.3
Android version:
13
Kernel build information:
Linux localhost 4.14.190-lineage-gef0cb31b13 #4 SMP PREEMPT Fri Jun 23 13:11:47 CEST 2023 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-A705FN
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.x11 versionCode:15