termux / termux-packages

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

[Bug]: Valgrind fatal error #19827

Open kyufie opened 4 months ago

kyufie commented 4 months ago

Problem description

Valgrind refused to work and printed an assertion error. However, for some binaries, Valgrind reported a different error.

What steps will reproduce the bug?

Using a simple Hello World program.

$ valgrind ./a.out
==12692== Memcheck, a memory error detector
==12692== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==12692== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==12692== Command: ./a.out
==12692==

valgrind: /home/builder/.termux-build/valgrind/src/coregrind/m_redir.c:796 (void vgPlain_redir_add_ifunc_target(Addr, Addr)): Assertion 'old' failed.

host stacktrace:
==12692==    at 0x5802EB10: ??? (in /data/data/com.termux/files/usr/libexec/valgrind/memcheck-arm64-linux)
==12692==    by 0x5802EE4B: ??? (in /data/data/com.termux/files/usr/libexec/valgrind/memcheck-arm64-linux)
==12692==    by 0x5802EE27: ??? (in /data/data/com.termux/files/usr/libexec/valgrind/memcheck-arm64-linux)
==12692==    by 0x58041BB3: ??? (in /data/data/com.termux/files/usr/libexec/valgrind/memcheck-arm64-linux)
==12692==    by 0x5809247B: ??? (in /data/data/com.termux/files/usr/libexec/valgrind/memcheck-arm64-linux)
==12692==    by 0x580A180B: ??? (in /data/data/com.termux/files/usr/libexec/valgrind/memcheck-arm64-linux)
==12692==    by 0xFFFFFFFFFFFFFFFF: ???

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 12692)
==12692==    at 0x5C8C460: _vgnU_ifunc_wrapper (in /data/data/com.termux/files/usr/libexec/valgrind/vgpreload_core-arm64-linux.so)
client stack range: [0x1FFEFF8000 0x1FFF000FFF] client SP: 0x1FFEFFC6D0
valgrind stack range: [0x1002DB8000 0x1002EB7FFF] top usage: 12432 of 1048576

Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.

For some system commands such as ls, Valgrind reported a different error:

$ valgrind ls
valgrind: mmap(0x171000, 712704) failed in UME with error 22 (Invalid argument).
valgrind: this can be caused by executables with very large text, data or bss segments.

Output on Debian 12 chroot:

$ valgrind ls
==16411== Memcheck, a memory error detector
==16411== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==16411== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==16411== Command: ls
==16411==
builder
==16411==
==16411== HEAP SUMMARY:
==16411==     in use at exit: 19,544 bytes in 8 blocks
==16411==   total heap usage: 48 allocs, 40 frees, 60,643 bytes allocated
==16411==
==16411== LEAK SUMMARY:
==16411==    definitely lost: 0 bytes in 0 blocks
==16411==    indirectly lost: 0 bytes in 0 blocks
==16411==      possibly lost: 0 bytes in 0 blocks
==16411==    still reachable: 19,544 bytes in 8 blocks
==16411==         suppressed: 0 bytes in 0 blocks
==16411== Rerun with --leak-check=full to see details of leaked memory
==16411==
==16411== For lists of detected and suppressed errors, rerun with: -s
==16411== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

What is the expected behavior?

No response

System information

termux-info:

Termux Variables:
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=944
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.utermux.dev/termux/termux-main stable main
# root-repo (sources.list.d/root.list)
deb https://mirrors.utermux.dev/termux/termux-root root stable
# x11-repo (sources.list.d/x11.list)
deb https://mirrors.utermux.dev/termux/termux-x11 x11 main
Updatable packages:
proot/stable 5.1.107-64 aarch64 [upgradable from: 5.1.107-63]
vulkan-tools/stable 1.3.282 aarch64 [upgradable from: 1.3.280]
termux-tools version:
1.42.0
Android version:
14
Kernel build information:
Linux localhost 5.15.94-android13-8-00001-g171753a15b59-ab11001737 #1 SMP PREEMPT Wed Oct 25 05:41:09 UTC 2023 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
23021RAA2Y
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.x11 versionCode:14
com.termux.styling versionCode:31
twaik commented 4 months ago

Reference: https://github.com/termux/termux-packages/pull/19741#issuecomment-2049566729

cloudiesky commented 2 days ago

bug still exist,

TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=9446
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.1
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.pku.edu.cn/termux/termux-main/ stable main
# x11-repo (sources.list.d/x11.list)
deb https://mirrors.pku.edu.cn/termux/termux-x11/ x11 main
Updatable packages:
All packages up to date
termux-tools version:
1.43.4
Android version:
14
Kernel build information:
Linux localhost 6.1.57-android14-11-o-g66975c18464e #1 SMP PREEMPT Wed Aug  7 12:40:14 UTC 2024 aarch64 Android
Device manufacturer:
OnePlus
Device model:
OPD2404
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.widget versionCode:13
com.termux.x11 versionCode:15
com.termux.api versionCode:51